Hi,
I am trying to convert an algorithm to CUDA and replacing LAPACKE_cheev() by cusolverDnCheevd(). However, I am having big trouble in getting the eigenvectors right. eigenvalues come alright.
LAPACKE_cheev() call is as follows:
LAPACKE_cheev(LAPACK_ROW_MAJOR, ‘V’, ‘U’, 3, hk, 3, eig);
cusolverDnCheevd() call is as follows:
const cuComplex cmplx_1=make_cuComplex(1.0f, 0.0f);
const cuComplex cmplx_0=make_cuComplex(0.0f, 0.0f);
cuComplex * hk_clone;
cudaMalloc((void**) &hk_clone, sizeof(cuComplex)33);
cudaMemcpy(hk_clone, hk_host, sizeof(cuComplex)33, cudaMemcpyHostToDevice);
//from ROW-major to COL-major
cublasCgeam(blasHandle, CUBLAS_OP_T, CUBLAS_OP_N, 3, 3, &cmplx_1, hk_clone, 3, &cmplx_0, hk_clone, 3, hk, 3);
cudaFree(hk_clone);
float * eig;
cudaMalloc ((void**)&eig, sizeof(float)*3);
int lwork = 0;
int devInfo = NULL;
cuFloatComplex d_work = NULL;
cudaMalloc ((void)&devInfo, sizeof(int));
cusolverDnCheevd_bufferSize(solverHandle, CUSOLVER_EIG_MODE_VECTOR, CUBLAS_FILL_MODE_UPPER, 3, hk, 3, eig, &lwork);
cudaMalloc((void**)&d_work, sizeof(cuFloatComplex)*lwork);
cusolverDnCheevd(solverHandle, CUSOLVER_EIG_MODE_VECTOR, CUBLAS_FILL_MODE_UPPER, 3, hk, 3, eig, d_work, lwork, devInfo);
All of the above calls show success, devInfo comes out to 0. So, I don’t see any issues. However, the eigenvectors are completely different than what LAPACKE_cheev() produces.
4.868580818176269531250000
4.868581771850585937500000
4.868581771850585937500000
Above are the eigenvalues both of them outputs.
But, the eigenvectors that LAPACKE_cheev() outputs are
x = 0.517591893672943115234375 y = 0.283592641353607177734375
x = -0.392975419759750366210938 y = -0.705155372619628906250000
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = -0.806862354278564453125000 y = -0.025435641407966613769531
x = -0.489541530609130859375000 y = -0.329659223556518554687500
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = 1.000000000000000000000000 y = 0.000000000000000000000000
and eigenvectors that cusolverDnCheevd() outputs are
x = -0.285086363554000854492188 y = -0.718063473701477050781250
x = 0.580177545547485351562500 y = 0.257884830236434936523438
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = -0.226605519652366638183594 y = -0.593094050884246826171875
x = -0.701853394508361816406250 y = -0.322941243648529052734375
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = 0.000000000000000000000000 y = 0.000000000000000000000000
x = 1.000000000000000000000000 y = 0.000000000000000000000000
Any ideas what might be the problem?
I couldn’t find any single example in the Internet or in cuda samples library that shows the use of complex variables. Not sure what I am doing wrong. Please help.