<?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 Hi Maria, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185598#M29555</link>
    <description>&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;You are absolutely correct!&lt;/P&gt;&lt;P&gt;I am really embarrassed to have made such a mistake, but I really thank you for noticing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nikolas&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jun 2020 23:42:37 GMT</pubDate>
    <dc:creator>Pat__Nikolas</dc:creator>
    <dc:date>2020-06-01T23:42:37Z</dc:date>
    <item>
      <title>segmentation fault in mkl_sparse_d_export_csr_i4_avx2</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185594#M29551</link>
      <description>&lt;P&gt;Hi *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use the pardiso direct solver in my code. My sparse matrix was stored in COO format so I am trying to convert it to CSR3 and run the pardiso solver. My problem is that I get the title's segmentation fault. I checked the input/output parameters and I think that I am not making any mistakes. Here is the code:&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;#include "mkl.h"
#include "mkl_spblas.h"
#include &amp;lt;iostream&amp;gt;

/* Internal solver memory pointer pt, */
/* 32-bit: int pt[64]; 64-bit: long int pt[64] */
/* or void *pt[64] should be OK on both architectures */
void *pt[64];
MKL_INT mtype = 11; // Real and nonsymmetric matrix
MKL_INT iparm[64];

sparse_matrix_t A_imkl_coo = 0;
sparse_matrix_t A_imkl_csr = 0;
MKL_INT *A_mkl_csr_ia = NULL;
MKL_INT *col_indx = NULL;
double *values = NULL;

// This one is in the initialization part:
for ( int i = 0; i &amp;lt; 64; ++i )
	pt&lt;I&gt; = 0;
iparm[0] = 0;
pardisoinit( pt, &amp;amp;mtype, iparm );

=======================================

// These are in the computation loop

// Create a sparse MKL object in COO format
sparse_status_t ret_err;
if( A_imkl_coo != NULL )
        ret_err = mkl_sparse_destroy(A_imkl_coo); // I am running this in a loop so I do not want any mem leaks
ret_err = mkl_sparse_d_create_coo( &amp;amp;A_imkl_coo, SPARSE_INDEX_BASE_ONE, 2 * NN, 2 * NN, 4 * NNZ, IT, JT, T);
if( ret_err == SPARSE_STATUS_SUCCESS )
        printf( "Successful MKL sparse matrix operation: %s : %d\n", __FILE__, __LINE__);
else
        abort();

// Create a CSR handle from the COO
const sparse_operation_t operation = SPARSE_OPERATION_NON_TRANSPOSE;
ret_err = mkl_sparse_convert_csr( A_imkl_coo, operation, &amp;amp;A_imkl_csr);
if( A_imkl_csr != NULL )
        ret_err = mkl_sparse_destroy(A_imkl_csr);
if( ret_err == SPARSE_STATUS_SUCCESS )
        printf( "Successfully converted internal MKL sparse matrix representation from coo to csr: %s : %d\n", __FILE__, __LINE__);

// Now export the CSR data to be used in the pardiso solver
sparse_index_base_t indexing = SPARSE_INDEX_BASE_ZERO;
MKL_INT rows;
MKL_INT cols;
MKL_INT *rows_start = NULL;
MKL_INT *rows_end = NULL;
ret_err = mkl_sparse_d_export_csr(A_imkl_csr, &amp;amp;indexing, &amp;amp;rows, &amp;amp;cols, &amp;amp;rows_start, &amp;amp;rows_end, &amp;amp;col_indx, &amp;amp;values );
if( ret_err == SPARSE_STATUS_SUCCESS )
        printf( "Successfully exported internal MKL CSR representation: %s : %d\n", __FILE__, __LINE__);
else
        abort();
if( indexing == SPARSE_INDEX_BASE_ONE )
        printf("detected indexing base one\n");
else
        printf("detected indexing base zero\n");

// Pardiso solver expects CSR3 format so "convert" that one as well
A_mkl_csr_ia = (MKL_INT*)realloc(A_mkl_csr_ia, (rows+1)* sizeof(MKL_INT));
for ( MKL_INT i = 0; i &amp;lt; rows; ++i )
        A_mkl_csr_ia&lt;I&gt; = rows_start&lt;I&gt;;
A_mkl_csr_ia[rows] = rows_end[rows-1];


const MKL_INT maxfct = 1;
const MKL_INT mnum = 1;
const MKL_INT phase = 13;
const MKL_INT n = 2*NN;
const MKL_INT msglvl = 1;
      MKL_INT error;
      MKL_INT perm;
const MKL_INT nrhs = 1;
pardiso (pt, &amp;amp;maxfct, &amp;amp;mnum, &amp;amp;mtype, &amp;amp;phase, &amp;amp;n, values, A_mkl_csr_ia, col_indx, &amp;amp;perm, &amp;amp;nrhs, iparm, &amp;amp;msglvl, node-&amp;gt;PHI/*void* b */, x, &amp;amp;error);
if( error != 0 ) {
	printf( "Error in intel mkl sparse linear solver: %d\n", error);
	exit(EXIT_FAILURE);
}&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;I am using gcc 9.3.0 on debian testing, mkl 2020.0.166 and these are the relevant link options:&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:bash; class-name:dark;"&gt;-fopenmp -Wl,--start-group /opt/imkl-2020.0.166/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64/libmkl_gf_lp64.a /opt/imkl-2020.0.166/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64/libmkl_gnu_thread.a /opt/imkl-2020.0.166/compilers_and_libraries_2020.0.166/linux/mkl/lib/intel64/libmkl_core.a -Wl,--end-group -lgomp -lpthread -lm -ldl -pthread -lm  -lgfortran&lt;/PRE&gt;

&lt;P&gt;I started converting the COO to CSR format on my own, but I would really like to find out what I am doing wrong :)&lt;BR /&gt;&lt;BR /&gt;Thank you - Regards&lt;/P&gt;
&lt;P&gt;Nikolas&lt;BR /&gt;&lt;BR /&gt;edit: added compiler/imkl and linking information&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 15:55:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185594#M29551</guid>
      <dc:creator>Pat__Nikolas</dc:creator>
      <dc:date>2020-06-01T15:55:22Z</dc:date>
    </item>
    <item>
      <title>Could you give us the</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185595#M29552</link>
      <description>&lt;P&gt;Could you give us the standalone example which we could compile and launch for reproducing the problem?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 16:45:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185595#M29552</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2020-06-01T16:45:04Z</dc:date>
    </item>
    <item>
      <title>Thank you for the reply.</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185596#M29553</link>
      <description>&lt;P&gt;Thank you for the reply. Unfortunately it is not that simple to come up with a minimum standalone reproducible code of the original code as it is a typical scientific computing spaghetti code. However, I get the same error when I try with the attached code. The compilation command I used is included in the beginning of the source. I tried running it step by step with gdb but it crashes as soon as it goes into the export_csr function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 22:15:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185596#M29553</guid>
      <dc:creator>Pat__Nikolas</dc:creator>
      <dc:date>2020-06-01T22:15:00Z</dc:date>
    </item>
    <item>
      <title>Hi Nikolas,I think the issue</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185597#M29554</link>
      <description>&lt;P&gt;Hi Nikolas,&lt;BR /&gt;I think the issue is happening because you destroy the handle for the matrix in CSR format (A_imkl_csr) before actually doing export from this handle.&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;ret_err = mkl_sparse_convert_csr( A_imkl_coo, operation, &amp;amp;A_imkl_csr);
if( A_imkl_csr != NULL )
ret_err = mkl_sparse_destroy(A_imkl_csr);
...
ret_err = mkl_sparse_d_export_csr(A_imkl_csr, &amp;amp;indexing, &amp;amp;rows, &amp;amp;cols, &amp;amp;rows_start, &amp;amp;rows_end, &amp;amp;col_indx, &amp;amp;values );

&lt;/PRE&gt;

&lt;P&gt;Best regards,&lt;BR /&gt;Maria&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 23:24:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185597#M29554</guid>
      <dc:creator>MariaZh</dc:creator>
      <dc:date>2020-06-01T23:24:28Z</dc:date>
    </item>
    <item>
      <title>Hi Maria,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185598#M29555</link>
      <description>&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;You are absolutely correct!&lt;/P&gt;&lt;P&gt;I am really embarrassed to have made such a mistake, but I really thank you for noticing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nikolas&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 23:42:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185598#M29555</guid>
      <dc:creator>Pat__Nikolas</dc:creator>
      <dc:date>2020-06-01T23:42:37Z</dc:date>
    </item>
    <item>
      <title>Hi Nikolas,No worries. Please</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185599#M29556</link>
      <description>&lt;P&gt;Hi Nikolas,&lt;BR /&gt;No worries. Please, let us know if you have any questions!&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Maria&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 00:00:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/segmentation-fault-in-mkl-sparse-d-export-csr-i4-avx2/m-p/1185599#M29556</guid>
      <dc:creator>MariaZh</dc:creator>
      <dc:date>2020-06-02T00:00:03Z</dc:date>
    </item>
  </channel>
</rss>

