Page 1 of 1

culaSgemm does not return any results!

PostPosted: Fri Sep 30, 2011 8:53 am
by nabeel_nas
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?


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];


    culaGetErrorInfoString(status, culaGetErrorInfo(), buf, sizeof(buf));
    printf("%s\n", buf);


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();

    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);

  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");


    return EXIT_SUCCESS;

Re: culaSgemm does not return any results!

PostPosted: Fri Sep 30, 2011 11:30 am
by john
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

Re: culaSgemm does not return any results!

PostPosted: Sun Oct 02, 2011 9:32 pm
by nabeel_nas
Thanks for the help! After I added culablas.h header it worked! I didn't see this header mentioned in the docummentation!