Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7234 Discussions

Lapack: DSTEVR produces SIGSEGV when all eigenvectors are queried

clemens_adolphs
Beginner
378 Views
Dear all,
I am using DSTEVR to diagonalize a symmetric tridiagonal matrix. It works fine when I only want none or some of the eigenvectors. For a matrix of dimension N, computing the first N-1 eigenvectors/eigenvalues works fine.
However, if I want all eigenvectors, DSTEVR crashes with a segmentation fault in mkl_lapack_dlarre

A minimum example is
#include #include using namespace std; extern "C" { void dstevr( char *jobz, char *range, int *n, double * d, double *e, double *vl, double *vu, int *il, int *iu, double *abstol, int *m, double *w, double *z, int *ldz, int *isuppz, double *work, int *lwork, int *iwork, int *liwork, int *info); void dstevr_( char *jobz, char *range, int *n, double * d, double *e, double *vl, double *vu, int *il, int *iu, double *abstol, int *m, double *w, double *z, int *ldz, int *isuppz, double *work, int *lwork, int *iwork, int *liwork, int *info); } int main() { int n = 3; double* d = (double*) malloc(n*sizeof(double)); double* e = (double*) malloc((n-1)*sizeof(double)); d[0] = 1; d[1] = 2; d[2] = 3; e[0] = 0.2; e[1] = 0.1; double* ee = (double*) malloc(n*sizeof(double)); double* ev = (double*) malloc(n*n*sizeof(double)); //Fill with stuff so we see what dstevr has changed for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ev[i*n+j] = (double)(i*n+j); //Allocate work arrays int lwork = 60*n; int liwork = 30*n; double* work = (double*) malloc(lwork*sizeof(double)); int* iwork = (int*) malloc(liwork*sizeof(int)); //Prepare arguments to FORTRAN function char jobz = 'V'; char range = 'A'; double abstol = 0.0; int m; int ldz = n; int* isuppz = (int*) malloc(sizeof(int)*2*n); for (int i = 0; i < 2 * n; i++) isuppz = 0; int result = 0; double vl = 0, vu = 0; int il = 1, iu = n - 1; dstevr_(&jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, &m, ee, ev, &ldz, isuppz, work, &lwork, iwork, &liwork,&result); // int dummy = -1; // dstevr(&jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, &m, ee, ev, &ldz, isuppz, work, &dummy, iwork, &dummy ,&result); // cout << "Optimal lwork: " << (int) work[0] << "Optmial liwork" << iwork[0] << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cout << ev[i*n+j] << "\t"; cout << endl; } cout << "ISUPPZ: "; for (int i = 0; i < 2 * n; i++) cout << isuppz << " "; cout << endl; return 0; }

I am linking against -lmkl, but it doesn't really matter.
The same code runs fine without segmentation faults if linked against other lapack implementations.

The MKL version in use is 10.0.1.014
0 Kudos
1 Reply
Gennady_F_Intel
Moderator
378 Views
Quoting - clemens_adolphs
Dear all,
I am using DSTEVR to diagonalize a symmetric tridiagonal matrix. It works fine when I only want none or some of the eigenvectors. For a matrix of dimension N, computing the first N-1 eigenvectors/eigenvalues works fine.
However, if I want all eigenvectors, DSTEVR crashes with a segmentation fault in mkl_lapack_dlarre

A minimum example is
#include #include using namespace std; extern "C" { void dstevr( char *jobz, char *range, int *n, double * d, double *e, double *vl, double *vu, int *il, int *iu, double *abstol, int *m, double *w, double *z, int *ldz, int *isuppz, double *work, int *lwork, int *iwork, int *liwork, int *info); void dstevr_( char *jobz, char *range, int *n, double * d, double *e, double *vl, double *vu, int *il, int *iu, double *abstol, int *m, double *w, double *z, int *ldz, int *isuppz, double *work, int *lwork, int *iwork, int *liwork, int *info); } int main() { int n = 3; double* d = (double*) malloc(n*sizeof(double)); double* e = (double*) malloc((n-1)*sizeof(double)); d[0] = 1; d[1] = 2; d[2] = 3; e[0] = 0.2; e[1] = 0.1; double* ee = (double*) malloc(n*sizeof(double)); double* ev = (double*) malloc(n*n*sizeof(double)); //Fill with stuff so we see what dstevr has changed for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) ev[i*n+j] = (double)(i*n+j); //Allocate work arrays int lwork = 60*n; int liwork = 30*n; double* work = (double*) malloc(lwork*sizeof(double)); int* iwork = (int*) malloc(liwork*sizeof(int)); //Prepare arguments to FORTRAN function char jobz = 'V'; char range = 'A'; double abstol = 0.0; int m; int ldz = n; int* isuppz = (int*) malloc(sizeof(int)*2*n); for (int i = 0; i < 2 * n; i++) isuppz = 0; int result = 0; double vl = 0, vu = 0; int il = 1, iu = n - 1; dstevr_(&jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, &m, ee, ev, &ldz, isuppz, work, &lwork, iwork, &liwork,&result); // int dummy = -1; // dstevr(&jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, &m, ee, ev, &ldz, isuppz, work, &dummy, iwork, &dummy ,&result); // cout << "Optimal lwork: " << (int) work[0] << "Optmial liwork" << iwork[0] << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cout << ev[i*n+j] << "t"; cout << endl; } cout << "ISUPPZ: "; for (int i = 0; i < 2 * n; i++) cout << isuppz << " "; cout << endl; return 0; }

I am linking against -lmkl, but it doesn't really matter.
The same code runs fine without segmentation faults if linked against other lapack implementations.

The MKL version in use is 10.0.1.014

the same as http://software.intel.com/en-us/forums/showthread.php?t=69963
0 Kudos
Reply