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

Some subroutines of lapack in mkl gives Segmentation fault for matrix dimension larger than 1020

Zhang__Simon
Beginner
405 Views

OS: Ubuntu 18.04.2 server, kernel 4.15.0-50-generic. MKL provided by intel parallel studio xe 2019.3.

The C code reproducing the error

#include <stdlib.h>
#include <stdio.h>
#include <mkl.h>

#define N 1021 

int main(){
printf("begin main\n");
double m,a[N*N];
lapack_int n1=N, n2=N;
for(size_t i=0;i<N*N;i++){
if(i%(N+1)==0){
a=(double) rand()/RAND_MAX;
}
else {a=0;}
}
lapack_int info;
printf("begin lapack\n");
info = LAPACKE_dsyevd(LAPACK_ROW_MAJOR, 'V','U', n1, a, n2, m);
printf("%d: end lapack\n", info);
return 0;
}

This code gave correct results for matrix smaller than 1020*1020, while gave Segmentation fault when N>1020. The error persists for icc, gcc, linking options as simple as -mkl for icc or full linking and compiling options as advised by linking advisor. dsteqr routine seems have similar issues.

I am new to directly using lower level routines in MKL, so there may also be some problems in my code above. Though it works well for smaller matrix. 

Thanks in advance.

0 Kudos
1 Reply
Zhang__Simon
Beginner
405 Views

I have solved the issue. It is because the default soft limit on stack size is too small for declaring large array in main function(stack). Just try `ulimit -s unlimited`, everything works fine then.

0 Kudos
Reply