<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Mystery SIGSEGV errors with zheevd functions in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Mystery-SIGSEGV-errors-with-zheevd-functions/m-p/1191055#M29737</link>
    <description>&lt;P&gt;This may be a really silly question, but my colleagues and I are running out of ideas. So, here is the problem:&lt;/P&gt;
&lt;P&gt;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: &lt;A href="https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_zheevd_row.c.htm," target="_blank" rel="noopener"&gt;https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_zheevd_row.c.htm,&lt;/A&gt; 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.&lt;/P&gt;
&lt;P&gt;I used the following command for compilation:&lt;/P&gt;
&lt;P&gt;icc main.cc -o lcrg -DSIZE=700 -Ofast -fopenmp -lmkl_rt -lm&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Any thoughts are appreciated.&lt;/P&gt;
&lt;P&gt;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)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;iostream&amp;gt;

#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 &amp;lt;&amp;lt; "Hello World" &amp;lt;&amp;lt; 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 &amp;lt; N; ++i) {
        for (int j = 0; j &amp;lt; 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);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it matters, I used icc v19.1.1.217 with gcc v8.3 and v10.0 on a x64 linux machine.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jul 2020 18:47:03 GMT</pubDate>
    <dc:creator>Jaeger__Philipp</dc:creator>
    <dc:date>2020-07-09T18:47:03Z</dc:date>
    <item>
      <title>Mystery SIGSEGV errors with zheevd functions</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Mystery-SIGSEGV-errors-with-zheevd-functions/m-p/1191055#M29737</link>
      <description>&lt;P&gt;This may be a really silly question, but my colleagues and I are running out of ideas. So, here is the problem:&lt;/P&gt;
&lt;P&gt;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: &lt;A href="https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_zheevd_row.c.htm," target="_blank" rel="noopener"&gt;https://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_lapack_examples/lapacke_zheevd_row.c.htm,&lt;/A&gt; 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.&lt;/P&gt;
&lt;P&gt;I used the following command for compilation:&lt;/P&gt;
&lt;P&gt;icc main.cc -o lcrg -DSIZE=700 -Ofast -fopenmp -lmkl_rt -lm&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Any thoughts are appreciated.&lt;/P&gt;
&lt;P&gt;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)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;cstdlib&amp;gt;
#include &amp;lt;cstdio&amp;gt;
#include &amp;lt;iostream&amp;gt;

#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 &amp;lt;&amp;lt; "Hello World" &amp;lt;&amp;lt; 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 &amp;lt; N; ++i) {
        for (int j = 0; j &amp;lt; 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);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it matters, I used icc v19.1.1.217 with gcc v8.3 and v10.0 on a x64 linux machine.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 18:47:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Mystery-SIGSEGV-errors-with-zheevd-functions/m-p/1191055#M29737</guid>
      <dc:creator>Jaeger__Philipp</dc:creator>
      <dc:date>2020-07-09T18:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Mystery SIGSEGV errors with zheevd functions</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Mystery-SIGSEGV-errors-with-zheevd-functions/m-p/1191176#M29739</link>
      <description>&lt;P&gt;Could you try to allocate all working arrays dynamically instead of on the stack?&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;//MKL_Complex16 mat&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;N&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;N&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN&gt; MKL_Complex16* mat = (MKL_Complex16*)mkl_malloc( N*N*sizeof(MKL_Complex16), 64);&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN&gt;&amp;nbsp;or by using malloc(...) if you want...&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;&lt;SPAN&gt;and release the allocated memory at the very end of this program by mkl_free() or free(..)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jul 2020 02:27:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Mystery-SIGSEGV-errors-with-zheevd-functions/m-p/1191176#M29739</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2020-07-10T02:27:46Z</dc:date>
    </item>
  </channel>
</rss>

