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

Eigenvalues and Eygenvectors using dsyevr ...

gatts
Beginner
1,119 Views

Well, i am starting with MKL, using C++, and I test the "dsyevr " of Lapack, to compute the eigenvalues of a matrix, but i was "shock" when I try a matrix with dimension bigger or equal than 710, after that the program said "segmentation fault", but when I use a matrix of 709 it works, really good... so my question is that if the command "dsyevr" has a limitation for the size of the matrix to calculate the corresponding EV

The part of the code is :

N=709

[cpp] char jobz = 'N'; 
char range = 'A';
char uplo = 'U';
int n = N;
double H;
int lda = N;
int lwork = 26*N;
double vl, vu;
int il, iu;
double abstol = 1.0;
int m;
double w;
double z;
int isuppz;
int ldz = N;
double work[lwork];
int liwork = 10*N;
int iwork[liwork];
int info;

dsyevr(&jobz, &range, &uplo, &n, *H, &lda, &vl, &vu, &il, &iu, &abstol, &m, w, *z, &ldz, &isuppz, work, &lwork, iwork,&liwork, &info);[/cpp]

Thanks in advances

0 Kudos
1 Solution
Trifon
Novice
1,119 Views
Hello,
The declaration double H it does not allocate a continuous memory block of size N x N x sizeof(double) bytes. It allocates a space suitable for containing a set of N pointers to N arrays of doubles each one containing N doubles.
Try allocating heap memory for your matrix using this:
double *H = malloc( N*N*sizeof(double) );
Pointers to managed (jagged) array array objectsare not the same as pointers to unmanaged memory blocks the later being the sort of pointers MKL is happy with.

View solution in original post

0 Kudos
15 Replies
gatts
Beginner
1,119 Views
there is someone there????

0 Kudos
TimP
Honored Contributor III
1,119 Views

As you have neglected to mention the subject, we might guess that you haven't considered stack size settings or the possibility of an Intel compiler heap-arrays option. There certainly is no set limit such as you mention; the default is likely to be different among various operating systems.

0 Kudos
gatts
Beginner
1,119 Views
The subject?? also...

Quoting - gatts

stack size settings or the possibility of an Intel compiler heap-arrays option

What do you mean with that?, because I didn't understand..

I am declared noob with this...

0 Kudos
Trifon
Novice
1,120 Views
Hello,
The declaration double H it does not allocate a continuous memory block of size N x N x sizeof(double) bytes. It allocates a space suitable for containing a set of N pointers to N arrays of doubles each one containing N doubles.
Try allocating heap memory for your matrix using this:
double *H = malloc( N*N*sizeof(double) );
Pointers to managed (jagged) array array objectsare not the same as pointers to unmanaged memory blocks the later being the sort of pointers MKL is happy with.
0 Kudos
gatts
Beginner
1,119 Views
Tnx!! i've already consulted that with a friend of mine and he give me the same answer with common words... jajaja...
The sort of pointers MKL is happy with.

and me too!! XD!!

I'll just computed the eigenvalues for a 3k*3k matrix, in 10 , now the final frontier are the eigenvectors, it's a little messy....

0 Kudos
gatts
Beginner
1,119 Views

[cpp]  //Values for dsyevr
char jobz = 'N';
//char jobz = 'V';
char range = 'A';
char uplo = 'U';
int n = 1000;
int n2 = 2*n;
double *H = new double[n*n];
int lda = n;
int lwork = 26*n;
double vl, vu;
int il, iu;
double abstol = 1e-8;
int m = n;
int m2= 2*m;
int ldz = n;
//int ldz = n-1;
double *w= new double;
double *z= new double[ldz*m];
int isuppz;
//int *isuppz= new int[m2];
double *work = new double[lwork];
int liwork = 10*n;
int *iwork = new int[liwork];

//So at least we use MKL to compute the matrix eigenvalues
dsyevr(&jobz, &range, &uplo, &n, H, &lda, &vl, &vu, &il, &iu, &abstol, &m, w, z, &ldz, &isuppz, work, &lwork, iwork,&liwork, &info);


//dsyevr(&jobz, &range, &uplo, &n, H, &lda, &vl, &vu, &il, &iu, &abstol, &m, w, z, &ldz, isuppz, work, &lwork, iwork,&liwork, &info);



[/cpp]

So i build the the program this way but i can't get the eigenvectors, I tried with the lines "commented", but didn't work... what should I do??


0 Kudos
Gennady_F_Intel
Moderator
1,119 Views

Do you have other expectations?

Did you try other math libraries for such kind calculations?

Which CPU type are you running?

--Gennady

0 Kudos
gatts
Beginner
1,119 Views

Do you have other expectations?

Did you try other math libraries for such kind calculations?

Which CPU type are you running?

--Gennady

1.- Yes, I would like to use mkl for lineal calculus, I'am physics.. and I need to compute almost everyday, lineal problems, but restricted to low dim matrix due to computational power, that's because we use high level languages, the're easy to use but highly resource dependant.. not like c++.

And related to last sentence, because they're highly optimized for Intel processors...

2.- No, i didnt tried with other mkl libraries, this is my first time with this... and has been.. painful... very painful and also frustratitng... (moral level -100.0)

3.- I'm running on a quadcore Q9400 (just buyed.. wiii!!!!.... lol)

that's it's

0 Kudos
Anand_M_Intel
Employee
1,119 Views
Quoting - gatts

and me too!! XD!!

I'll just computed the eigenvalues for a 3k*3k matrix, in 10 , now the final frontier are the eigenvectors, it's a little messy....


Looks Good

0 Kudos
Michael_C_Intel4
Employee
1,119 Views
Hello,
why do you think that dsyevr didn't compute eigenvectors when you put jobz='V'?
Probably, you have been mislead by wrong info in MKL manual that ldz < max( 1, n ), really it should be ldz >= max( 1, n ), so set ldz = n to compute eigenvectors.
Michael.

0 Kudos
bigknife
Beginner
1,119 Views
Hi, gatts,
I just can get right eigenvalue. How did you make it out finally?
Thanks!
bigknife

0 Kudos
bigknife
Beginner
1,119 Views
Quoting - bigknife

My code is copy from gatts like that:

int nn = 500;
double* cov = new double[500*500];
FILE* fid = fopen("I:\cov500.dat", "rb");
fread(cov, sizeof(double), 500*500, fid);
fclose(fid);

char jobz = 'V';
char range = 'A';
char uplo = 'U';
double vl = 0.0, vu = 0.0;
int il = 0, iu = 0;
int lda = 500;
double abstol = 1e-8;
int lwork = 26*500;
int m = 500;
int ldz = 500;
double *w= new double[500];
double *z= new double[500*500];

int isuppz;
double *work = new double[lwork];
int liwork = 10*500;
int *iwork = new int[liwork];
int info;

dsyevr(&jobz, &range, &uplo, &nn, cov, &lda, &vl, &vu, &il, &iu, &abstol, &m, w, z, &ldz, &isuppz, work, &lwork, iwork,&liwork, &info);

I cannot get the right eigen vectors!
Somebody save me, please!

0 Kudos
leekeanloon
Beginner
1,119 Views
I face similar problem. I am using ifort version 10.1.018, mkl library version 10.0.4.023.
my call dsyevr as folllowed:
integer i,j,ktoff
double precision , dimension(0:17):: ev
double precision , dimension(1:18,1:18):: evect
double precision , dimension(0:17,0:17):: ttt
double precision work(18*64),dlamch
integer iwork(18*10), status, support(2*18)

toff=18
do 120 i=0, toff-1
do 120 j=9, toff-1
ttt(i,j)=1.d0
write(*,*) i,j,ttt(i,j)
120 continue

call dsyevr('v','a','l',toff,ttt,toff,0.d0,0.d0,0,0,dlamch('s'),
1 i,ev,evect,toff,support,work,toff*64,iwork,toff*10,status)
I compile with the option as followed:
ifort -O3 -fno-alias -heap-arrays 10 -align -132 -u -w90 -c test.f -o test.o -L/usr/local/intel/mkl/10.0.4.023/lib/em64t -lguide -lmkl -lmkl_lapack -lpthread
ifort -O3 -fno-alias -heap-arrays 10 -align -132 -u -w90 -o honeyN3L80 test.o -L/usr/local/intel/mkl/10.0.4.023/lib/em64t -lguide -lmkl -lmkl_lapack -lpthread
i keep on getting segmentation fault.
0 Kudos
leekeanloon
Beginner
1,119 Views
Quoting - leekeanloon
I face similar problem. I am using ifort version 10.1.018, mkl library version 10.0.4.023.
my call dsyevr as folllowed:
integer i,j,ktoff
double precision , dimension(0:17):: ev
double precision , dimension(1:18,1:18):: evect
double precision , dimension(0:17,0:17):: ttt
double precision work(18*64),dlamch
integer iwork(18*10), status, support(2*18)

toff=18
do 120 i=0, toff-1
do 120 j=9, toff-1
ttt(i,j)=1.d0
write(*,*) i,j,ttt(i,j)
120 continue

call dsyevr('v','a','l',toff,ttt,toff,0.d0,0.d0,0,0,dlamch('s'),
1 i,ev,evect,toff,support,work,toff*64,iwork,toff*10,status)
I compile with the option as followed:
ifort -O3 -fno-alias -heap-arrays 10 -align -132 -u -w90 -c test.f -o test.o -L/usr/local/intel/mkl/10.0.4.023/lib/em64t -lguide -lmkl -lmkl_lapack -lpthread
ifort -O3 -fno-alias -heap-arrays 10 -align -132 -u -w90 -o honeyN3L80 test.o -L/usr/local/intel/mkl/10.0.4.023/lib/em64t -lguide -lmkl -lmkl_lapack -lpthread
i keep on getting segmentation fault.


anybody there that can help?

0 Kudos
Gennady_F_Intel
Moderator
1,119 Views
Hi, the current MKL 10.2 Beta also fixed this problem. I attached an invitation letter.
It includes the steps on registration on the Beta. Feel free to let us know if you get any problem.
-- Gennady

0 Kudos
Reply