Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Jaeger__Philipp
Beginner
180 Views

Mystery SIGSEGV errors with zheevd functions

Jump to solution

This may be a really silly question, but my colleagues and I are running out of ideas. So, here is the problem:

We've been trying to run tests with MKL's diagonalization routines for hermitian matrices in C++. I built a program (see attachment) based on the example code here: https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke... slightly generalized for arbitrary matrix size. It works fine for small matrices (below N~=700), but above that, the binary terminates with SIGSEGV apparently before even entering the main function. It doesn't even print the test output in line 22.

I used the following command for compilation:

icc main.cc -o lcrg -DSIZE=700 -Ofast -fopenmp -lmkl_rt -lm

I also noticed that the eigenvalues calculated at N=700 are very different if I use gcc instead of icc. Which tells me that there is probably something wrong with my code.

Any thoughts are appreciated.

For some reason the forum will not allow me to upload the code, so I put it here (and excluded the helper routines from the example)

 

#include <cstdlib>
#include <cstdio>
#include <iostream>

#include "mkl_lapacke.h"

using namespace std;

void print_matrix( char* desc, int m, int n, MKL_Complex16* a, int lda );
void print_rmatrix( char* desc, int m, int n, double* a, int lda );

void get_random_matrix( int n, MKL_Complex16* buf);

#define UPLO 'L'

#ifndef SIZE
#define N 800
#else
#define N SIZE
#endif

using namespace std;

int main() {
    cout << "Hello World" << endl;

    //generate random matrix
    MKL_Complex16 mat[N*N];
    get_random_matrix(N, mat);

    //diagonalize
    double w[N];
    int info = 0;
    //info = LAPACKE_zheevd(LAPACK_ROW_MAJOR, 'V', UPLO, N, mat, N, w);
    printf( " CHEEVD Example Program Results\n" );
    if( info != 0 ) {
        printf( "The algorithm failed to compute eigenvalues.\n" );
        exit( 1 );
    }
    print_rmatrix("Eigenvalues", N, 1, w, N);
}

/* Auxiliary routine: generating a pseudo-random matrix */
void get_random_matrix( const int n, MKL_Complex16* buf) {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i = j) {
                buf[N*i+j] = {j+i/6.-2, 0};
            } else {
                buf[N*i+j] = {0, 0};
            }
        }
    }
    print_matrix("Matrix:", N, N, buf, N);
}

 

If it matters, I used icc v19.1.1.217 with gcc v8.3 and v10.0 on a x64 linux machine.

0 Kudos
1 Solution
Gennady_F_Intel
Moderator
172 Views

Could you try to allocate all working arrays dynamically instead of on the stack?

//MKL_Complex16 mat[N*N];

MKL_Complex16* mat = (MKL_Complex16*)mkl_malloc( N*N*sizeof(MKL_Complex16), 64); 

 or by using malloc(...) if you want...

and release the allocated memory at the very end of this program by mkl_free() or free(..)

View solution in original post

1 Reply
Gennady_F_Intel
Moderator
173 Views

Could you try to allocate all working arrays dynamically instead of on the stack?

//MKL_Complex16 mat[N*N];

MKL_Complex16* mat = (MKL_Complex16*)mkl_malloc( N*N*sizeof(MKL_Complex16), 64); 

 or by using malloc(...) if you want...

and release the allocated memory at the very end of this program by mkl_free() or free(..)

View solution in original post

Reply