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

Segmentation fault in dsyevr.

valeriyfedotov
初学者
1,776 次查看
Hello. I cant make dsyevr work properly. After some tries I wrote simple example of my problem. There are two calls to dsyevr that work and two that don't. But the arguments look fine and differ with working examples too little. I can't understand what's the problem. My MKL version is 10.2.1.017, and I compile it with command
icc stuff.c -I"opt/intel/mkl/10.2.1.017/include/" -L"/opt/intel/mkl/10.2.1.017/lib/" -lmkl_core -lmkl_intel_thread -lguide -lpthread -lmkl_lapack -lmkl_intel

Source code (all arrays are of 1000 elements to ensure there is enough memory):

#include
#include
#include

int main(){
int n = 3;
// 1 2 3
// 2 4 5
// 3 5 7
double M[1000] = {1, 2, 3, 2, 4, 5, 3, 5, 7};
double a,b;
int i,j;
double accuracy = 1e-6;
int m;
double eigVal[1000];
double eigVect[1000];
int isuppz[1000];
double work[1000];
int iwork[1000];
int many = 1000;
int status = 0;

// First two work:
a = -100;
b = 100;
dsyevr("V", "V", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

i = 1; j = 2;
dsyevr("V", "I", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

// Second two make segfaults:
i = 1; j = 3;
dsyevr("V", "I", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

dsyevr("V", "A", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

int k;
for(k = 0; k < n; k ++){
printf("%f ", eigVal);
}
printf("\n");

return 0;
}

0 项奖励
9 回复数
Gennady_F_Intel
主持人
1,776 次查看

Valery,
I guess you are trying to work on ia32 architecture, therefore you have to
1)setting L"/opt/intel/mkl/10.2.1.017/lib/32
and
2) using another linking line:
-Wl,--start-group -lmkl_intel -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread

As a result your linking line should be like:

icc stuff.c -I"opt/intel/mkl/10.2.1.017/include/" -L"/opt/intel/mkl/10.2.1.017/lib/32" -Wl,--start-group -lmkl_intel -lmkl_intel_thread -lmkl_core -Wl,--end-group -liomp5 -lpthread

for more info how to link properly please refer to the KB article: http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/
--Gennady

0 项奖励
valeriyfedotov
初学者
1,776 次查看
Thank you. But with this new linking line don't helped with segmentation fault.

Documentation says that when all eigenvalues are computed either by "A" parameter of by "I" parameter with i = 1 and j = n (this lines don't work), the routine references array isuppz, but it seems valid to me.
0 项奖励
Gennady_F_Intel
主持人
1,776 次查看

Well. At the first glance all input parameters are correct.
Valery, can you check the problem when all arrays will be allocated dynamically.
For the reproducing the problem - what is the CPU type you are working on?

0 项奖励
valeriyfedotov
初学者
1,776 次查看
My distro is Ubuntu 9.04, and processor Core 2 Quad Q9400.
I have done it with dynamical memory, but segfault remains. Also, it's intresting, when I uncomment bzero call, the program finishes normally.

#include
#include
#include
#include

int main(){
int n = 3;
// 1 2 3
// 2 4 5
// 3 5 7
double MM[1000] = {1, 2, 3, 2, 4, 5, 3, 5, 7};
double *M = (double *) malloc( sizeof(double) * 1000);
memcpy(M, MM, sizeof(double) * 9);
//bzero(M, sizeof(double) * 1000);
double a,b;
int i,j;
double accuracy = 1e-6;
int m;
double *eigVal = (double *) malloc( sizeof(double) * 1000);
double *eigVect = (double *) malloc( sizeof(double) * 1000);
int *isuppz = (int *) malloc( sizeof(int) * 1000);
double *work = (double *) malloc( sizeof(double) * 1000);
int *iwork = (int *) malloc( sizeof(int) * 1000);
int many = 1000;
int status = 0;

// First two work:
a = -100;
b = 100;
dsyevr("V", "V", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

i = 1; j = 2;
dsyevr("V", "I", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

// Second two make segfaults:
i = 1; j = 3;
dsyevr("V", "I", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

dsyevr("V", "A", "L", &n, M, &n, &a, &b, &i, &j, &accuracy, &m, eigVal, eigVect, &n, isuppz,
work, &many, iwork, &many, &status);

int k;
for(k = 0; k < n; k ++){
printf("%f ", eigVal);
}
printf("n");

return 0;
}

0 项奖励
Gennady_F_Intel
主持人
1,776 次查看
See, the list of officially supported operating systems:
..
Ubuntu* 8.10 (IA-32 / Intel 64)

But I will check the problem and will back if any upadates.


0 项奖励
Gennady_F_Intel
主持人
1,776 次查看

btw, originally i checked the problem on win32 and got the following output:
-0.600823 0.695387 11.905435

Do you have the similar results on ubuntu?

0 项奖励
valeriyfedotov
初学者
1,776 次查看

btw, originally i checked the problem on win32 and got the following output:
-0.600823 0.695387 11.905435

Do you have the similar results on ubuntu?


No, I have got -0.247820, 0.338816, 11.908962. But I checked them with maxima and online solvers, they are correct.

For myself, I made a = -1e20 and b = 1e20 with "V" option, and make error in my subroutine if dsyevr doesn't find all values.

And I will try it in Ubuntu 8.10 this week.
0 项奖励
Gennady_F_Intel
主持人
1,776 次查看
Quoting - valeriyfedotov

No, I have got -0.247820, 0.338816, 11.908962. But I checked them with maxima and online solvers, they are correct.

For myself, I made a = -1e20 and b = 1e20 with "V" option, and make error in my subroutine if dsyevr doesn't find all values.

And I will try it in Ubuntu 8.10 this week.
Valery,
the segmentaion problem was reproduced on RHEL 4, but no problem on win32. we will investigate the problem and will back to you asap.
--Gennady

0 项奖励
Gennady_F_Intel
主持人
1,776 次查看
Valery,
the segmentaion problem was reproduced on RHEL 4, but no problem on win32. we will investigate the problem and will back to you asap.
--Gennady


Valery,
the problem you reported has been fixed in the latest MKL v.10.2 Update 2 available now.
You can download it from intel registratin center.
The version is shipped with Intel Compiler Proffesional Edition, version 11.1 for Linux ( build 056 ).

See the log i 've got running your test:

[root@XXXXX 555076]# ./fix.out

FIRST STEPS

SECOND STEPS

THIRD STEPS

4 STEPS

-0.600823 0.695387 11.905435

--Gennady

0 项奖励
回复