Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- Hi Nikolas,I think the issue

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

Pat__Nikolas

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-01-2020
08:55 AM

160 Views

segmentation fault in mkl_sparse_d_export_csr_i4_avx2

Hi *,

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:

#include "mkl.h" #include "mkl_spblas.h" #include <iostream> /* 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 < 64; ++i ) pt= 0; iparm[0] = 0; pardisoinit( pt, &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( &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, &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, &indexing, &rows, &cols, &rows_start, &rows_end, &col_indx, &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 < rows; ++i ) A_mkl_csr_ia= rows_start; 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, &maxfct, &mnum, &mtype, &phase, &n, values, A_mkl_csr_ia, col_indx, &perm, &nrhs, iparm, &msglvl, node->PHI/*void* b */, x, &error); if( error != 0 ) { printf( "Error in intel mkl sparse linear solver: %d\n", error); exit(EXIT_FAILURE); }

I am using gcc 9.3.0 on debian testing, mkl 2020.0.166 and these are the relevant link options:

-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

I started converting the COO to CSR format on my own, but I would really like to find out what I am doing wrong :)

Thank you - Regards

Nikolas

edit: added compiler/imkl and linking information

5 Replies

Highlighted
##

Could you give us the standalone example which we could compile and launch for reproducing the problem?

Gennady_F_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-01-2020
09:45 AM

160 Views

Highlighted
##

Pat__Nikolas

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-01-2020
03:15 PM

160 Views

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.

Thanks again.

Highlighted
##

MariaZh

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-01-2020
04:24 PM

160 Views

Hi Nikolas,

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.

ret_err = mkl_sparse_convert_csr( A_imkl_coo, operation, &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, &indexing, &rows, &cols, &rows_start, &rows_end, &col_indx, &values );

Best regards,

Maria

Highlighted
##

Pat__Nikolas

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-01-2020
04:42 PM

160 Views

Hi Maria,

You are absolutely correct!

I am really embarrassed to have made such a mistake, but I really thank you for noticing.

Regards,

Nikolas

Highlighted
##

MariaZh

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-01-2020
05:00 PM

160 Views

Hi Nikolas,

No worries. Please, let us know if you have any questions!

Best regards,

Maria

For more complete information about compiler optimizations, see our Optimization Notice.