culaSgemm does not return any results!
3 posts
• Page 1 of 1
culaSgemm does not return any results!
I am doing a square matrix multiplication (32x32) using culaSgemm. The result should be returned in the output matrix C but it keeps returning all zeros! Did I miss anything in the code?
Thanks,
Nabeel
Thanks,
Nabeel
- Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <culapack.h>
#include <cublas.h>
void checkStatus(culaStatus status)
{
char buf[80];
if(!status)
return;
culaGetErrorInfoString(status, culaGetErrorInfo(), buf, sizeof(buf));
printf("%s\n", buf);
culaShutdown();
exit(EXIT_FAILURE);
}
int main(int argc, char** argv)
{
int M = 32;
int N = M;
int K = M;
int i;
culaStatus status;
printf("Initializing CULA\n");
status = culaInitialize();
checkStatus(status);
float* A = NULL;
float* B = NULL;
float* C = NULL;
printf("Allocating Matrices\n");
A = (float*)malloc(M*N*sizeof(float));
B = (float*)malloc(M*N*sizeof(float));
C = (float*)malloc(M*N*sizeof(float));
for (i=0; i<M*N; i++) A[i]=1.0;
for (i=0; i<M*N; i++) B[i]=2.0;
for (i=0; i<M*N; i++) C[i]=1.0;
printf("Calling culaSgemm\n");
status = culaSgemm('N', 'N', 32, 32, 32, 1.0, A, 32, B, 32, 0.0, C, 32);
checkStatus(status);
printf("The Multiply result is:\n");
for (i=0; i<32; i++) printf("C[%d]: %.1f\n",i, C[i]);
//for (i=0; i<9; i++) printf("B[%d]: %.1f\n",i, B[i]);
//for (i=0; i<9; i++) printf("A[%d]: %.1f\n",i, A[i]);
printf("Shutting down CULA\n");
culaShutdown();
free(A);
free(B);
free(C);
return EXIT_SUCCESS;
}
- nabeel_nas
- Posts: 2
- Joined: Wed Sep 07, 2011 9:21 pm
Re: culaSgemm does not return any results!
This example doesn't compile, are you sure it's correct? You are using culaSgemm, but I don't see the culablas.h header.
If you're looking to use CUBLAS, then you'll want cublasSgemm
If you're looking to use CUBLAS, then you'll want cublasSgemm
- john
- Administrator
- Posts: 587
- Joined: Thu Jul 23, 2009 2:31 pm
Re: culaSgemm does not return any results!
Thanks for the help! After I added culablas.h header it worked! I didn't see this header mentioned in the docummentation!
- nabeel_nas
- Posts: 2
- Joined: Wed Sep 07, 2011 9:21 pm
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest