culaSgemm does not return any results!

General CULA Dense (LAPACK & BLAS) support and troubleshooting. Use this forum if you are having a general problem or have encountered a bug.

culaSgemm does not return any results!

Postby nabeel_nas » Fri Sep 30, 2011 8:53 am

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

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!

Postby john » Fri Sep 30, 2011 11:30 am

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
john
Administrator
 
Posts: 587
Joined: Thu Jul 23, 2009 2:31 pm

Re: culaSgemm does not return any results!

Postby nabeel_nas » Sun Oct 02, 2011 9:32 pm

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


Return to CULA Dense Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron