runtime error (11) with culaSgels

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

runtime error (11) with culaSgels

Postby cledig » Fri Jul 09, 2010 1:41 pm

Hi,

I set up cula today because it looked like an easy way to solve a least square problem.
I am using cula 2.0 with cuda 3.1 on a GTX8800.

Different examples that come along with cula work fine.

To my problem.
I get a runtime error for culaSgels (even though the computed result is right).

My code:
Code: Select all
void CULATest()
{
   int rows = 4;
   int cols = 3;
   float *A = (float*)malloc(cols*rows*sizeof(float));
   float *b = (float*)malloc(rows*sizeof(float));
//   float *tau = (float*)malloc(rows*sizeof(float));

   init(b,rows,1,1.0);
   A[0] = 1;   A[4] = 1;   A[8] = 1;
   A[1] = 2;   A[5] = 4;   A[9] = 8;
   A[2] = 3;   A[6] = 9;   A[10] = 27;
   A[3] = 4;   A[7] = 16;   A[11] = 64;
   
   printMatrix(A,rows,cols);

   culaStatus status;
   status = culaInitialize();
   checkStatus(status);
   status = culaSgels('N', rows, cols, 1, A, rows, b, rows);
   checkStatus(status);
   culaShutdown();
   printMatrix(b,rows,1);
   free(A);
   free(b);
   return;
}


Thanks a lot for any help. I really hope its my fault...

Chris
cledig
 
Posts: 3
Joined: Fri Jul 09, 2010 7:01 am

Re: runtime error (11) with culaSgels

Postby cledig » Fri Jul 09, 2010 1:50 pm

Update:
Apparently I was including the C header. Including cudapack.hpp instead solved the problem.

However, a look in cudapack.h looks like it should work with a C++ compiler as well?

Thanks again.

Chris
cledig
 
Posts: 3
Joined: Fri Jul 09, 2010 7:01 am

Re: runtime error (11) with culaSgels

Postby cledig » Fri Jul 09, 2010 2:22 pm

Update again:
OK apparently this header thing was a wrong conclusion. Sorry for this. I reproduced the problem now.
In the following code the cudaMalloc is obviously useless. However, if it is commented out i get a runtime error for the culaSgels call.
Maybe it says somewhere in the manual that you need a cudaCall before you use cula. In this case sorry for this.

Code: Select all
   int rows = 4;
   int cols = 3;
   float *A = new float[cols*rows];
   float *b = new float[rows];   

   init(b,rows,1,1.0);
   A[0] = 1;   A[4] = 1;   A[8] = 1;
   A[1] = 2;   A[5] = 4;   A[9] = 8;
   A[2] = 3;   A[6] = 9;   A[10] = 27;
   A[3] = 4;   A[7] = 16;   A[11] = 64;
   
   float* Adev;
   cudaMalloc( (void**) &Adev, sizeof(float) * rows * cols );
   
   culaStatus status;
   status = culaInitialize();
   checkStatus(status);
   status = culaSgels('N', rows, cols, 1, A, rows, b, rows);
   checkStatus(status);
   culaShutdown();

   printMatrix(b,rows,1);

   delete[] A;
   delete[] b;
   return;


Chris.
cledig
 
Posts: 3
Joined: Fri Jul 09, 2010 7:01 am

Re: runtime error (11) with culaSgels

Postby john » Mon Jul 12, 2010 8:58 am

Hi Chris,
I was able to compile and run your code with some small modifications. For me it ran correctly both with and without the cudaMalloc call - there should be no need to "prime" the system with any cuda calls. I suspect there might be a problem in your environment or configuration/compilation.

I did have to comment out both init() and printMatrix() since I didn't have the definitions for those. Here is my final file:

Code: Select all
#include <stdio.h>
#include "cuda_runtime.h"
#include "culapack.hpp"

void checkStatus(culaStatus status)
{
    if(!status)
        return;
   
    if(status == culaArgumentError)
        printf("Invalid value for parameter %d\n", culaGetErrorInfo());
    else if(status == culaDataError)
        printf("Data error (%d)\n", culaGetErrorInfo());
    else if(status == culaBlasError)
        printf("Blas error (%d)\n", culaGetErrorInfo());
    else if(status == culaRuntimeError)
        printf("Runtime error (%d)\n", culaGetErrorInfo());
    else
        printf("%s\n", culaGetStatusString(status));
   
    culaShutdown();
}

int main() {

   int rows = 4;
   int cols = 3;
   float *A = new float[cols*rows];
   float *b = new float[rows];

   //init(b,rows,1,1.0);
   A[0] = 1;   A[4] = 1;   A[8] = 1;
   A[1] = 2;   A[5] = 4;   A[9] = 8;
   A[2] = 3;   A[6] = 9;   A[10] = 27;
   A[3] = 4;   A[7] = 16;   A[11] = 64;

   float* Adev;
//   cudaMalloc( (void**) &Adev, sizeof(float) * rows * cols );

   culaStatus status;
   status = culaInitialize();
   checkStatus(status);
   status = culaSgels('N', rows, cols, 1, A, rows, b, rows);
   checkStatus(status);
   culaShutdown();

//   printMatrix(b,rows,1);

   delete[] A;
   delete[] b;

   return 0;
}


I compiled and ran with:
Code: Select all
gcc -lcula -I/usr/local/cula/include -L/usr/local/cula/lib64 sgels.cpp -o sgels
export LD_LIBRARY_PATH=/usr/local/cula/lib64
./sgels


Please let us know if you're still having trouble and provide as much information as possible. So far we have been unable to reproduce it.
john
Administrator
 
Posts: 587
Joined: Thu Jul 23, 2009 2:31 pm


Return to CULA Dense Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron