Page 1 of 1

### problem with culaSsyevx

Posted: Thu Jul 07, 2011 8:27 am
Hello,

We cannot get culaSsyevx to work. It returns nothing for eigenvalues or eigenvectors. Note that culaSsyev works just fine for us.

We are using Ubuntu 11.04, CUDA 4.0, CULA R12 Linux 64 bit Premium.
Here is our code that gives the correct eigenvalues and eigenvectors when we use culaSsyev. For culaSsyevx, it returns all zero eigenvalues and eigenvectors.

Here is the code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cula.h>

int main(){
int N = 10;
int* c=NULL;
int* m=NULL;
float* A=NULL;
float* B=NULL;
float* d=NULL;
float vl=-100.0, vu=100.0;
int il=1, iu=10;
float abstol=0.0;

int M=N;

A = (float*)malloc(M*N*sizeof(float));
B = (float*)malloc(M*N*sizeof(float));
d = (float*)malloc(N*sizeof(float));
c = (int*)malloc(N*sizeof(float));

for (int i=0; i<N; i++) d[i]=1;

culaInitialize();
memset(A, 0, M*N*sizeof(float));
memset(B, 0, M*N*sizeof(float));

for (int i=0; i<M*N; i++) A[i]=i;
printf("A={\n");
for (int i=0; i<M*N; i++) {
printf("%3.2f ", A[i]);
if (!((i+1)%N)) printf("\n");
}
printf("}\n");

//culaSsyev ('V', 'U',N,A,N, d );
culaSsyevx('V','A','U',N,A,N,vl,vu,il,iu,abstol,m,d,A,N,c);

culaShutdown();

printf("eigenvalue={ ");
for (int i=0; i<N; i++) {
printf("%3.2f ", d[i]);
}
printf("}\n");
printf("eigenvectors={\n");
for (int i=0; i<N*M; i++) {
printf("%3.2f ", B[i]);
if (!((i+1)%N)) printf("\n");
}
printf("}\n");

for (int i=0; i<N; i++) if (c[i]!=0) printf("failed at %d!\n",i);
}

I would really appreciate your help.
Thank you very much!

### Re: problem with culaSsyevx

Posted: Thu Jul 07, 2011 10:03 am
Looks like you are reading and writing to A at the same time.

culaSsyevx('V','A','U',N,A,N,vl,vu,il,iu,abstol,m,d,A,N,c);

### Re: problem with culaSsyevx

Posted: Thu Jul 07, 2011 10:21 am
Sorry, we were trying different things and I copied the wrong version. When the call reads:

culaSsyevx('V','A','U',N,A,N,vl,vu,il,iu,abstol,m,d,B,N,c);

We still have a B populated with nothing (all zeroes).

Thanks again!

### Re: problem with culaSsyevx

Posted: Thu Jul 07, 2011 11:17 am
Have you checked the return code from your syevx call? The status returned might be indicating a problem.

### Re: problem with culaSsyevx

Posted: Thu Jul 07, 2011 12:32 pm
john wrote:Have you checked the return code from your syevx call? The status returned might be indicating a problem.

Thanks for the suggestion. We tried that and we seem to maybe (?) get an "Argument error" but culaGetErrorInfo returns nothing.

Here is the output:

Argument error; see culaGetErrorInfo for error code
(null)
eigenvalue={ 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 }
eigenvectors={
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
}

The code itself is now:
Code: Select all
`#include <stdio.h>#include <stdlib.h>#include <string.h>#include <cula.h>int main(){int N = 10;int M = N;float* A=NULL; //original matrixfloat* B=NULL; //eigenvectorsfloat* d=NULL; //eigenvaluesint* c=NULL; //where are the fails (ifail)int* m=NULL; //how many eigenvalues/*constants for syevx*/float vl=-100.0, vu=100.0;int il=1, iu=10;float abstol=0.0;/*constants for syevx*/culaStatus s;culaInfo i;char* buf;A = (float*)malloc(M*N*sizeof(float));B = (float*)malloc(M*N*sizeof(float));d = (float*)malloc(N*sizeof(float));c = (int*)malloc(N*sizeof(float));culaInitialize();memset(A, 0, M*N*sizeof(float));memset(B, 0, M*N*sizeof(float));for (int i=0; i<M*N; i++) A[i]=i;//culaSsyev ('V', 'U',N,A,N, d );s=culaSsyevx('V','A','U',N,A,N,vl,vu,il,iu,abstol,m,d,B,N,c);if(s != culaNoError) printf("%s\n", culaGetStatusString(s));i=culaGetErrorInfo();culaGetErrorInfoString(s, i, buf, 5000);printf("%s\n",buf);culaShutdown();printf("eigenvalue={ ");for (int i=0; i<N; i++) {printf("%3.2f ", d[i]);}printf("}\n");printf("eigenvectors={\n");for (int i=0; i<N*M; i++) {printf("%3.2f ", B[i]);if (!((i+1)%N)) printf("\n");}printf("}\n");for (int i=0; i<N; i++) if (c[i]!=0) printf("failed at %d!\n",i);}`

Thank you very much for your help!

### Re: problem with culaSsyevx

Posted: Thu Jul 07, 2011 12:59 pm
Your current code throws an "Argument error -12" indicating that argument 12 is bad.

This corresponds to 'm', the a pointer to integer that returns the number of eigenvalues found, where you are passing a null pointer. This would cause an obvious segmentation fault without argument error check.

`int m = 0;...s=culaSsyevx('V','A','U',N,A,N,vl,vu,il,iu,abstol,&m,d,B,N,c);`