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

Meeting Access Conflict when trying to use mkl_sparse_convert_csr

wen_qiang_z_
Beginner
342 Views

Hi, has anyone encounterd the situation I met? All I did was try to convert a sparse matrix in CSC format to CSR format.

At the foremost , I use mkl_sparse_z_creat_csc to create a matrix in CSC format, and the stat is '0', which shows that the creation is successful, and I use mkl_sparse_convert_csr to get matrix in CSR format. I`ve tried this function using a small matrix and surely it works, however, when I use it to convert a big matrix, the compiler suddenly occur to prompt me that there exists an Access Conflict when running the convert function, and I have no idea why this hint comes to me, so is there anyone knows why?

0 Kudos
7 Replies
Gennady_F_Intel
Moderator
342 Views

what mkl version do you use? we don't know such problem with the latest 2019.

wen_qiang_z_
Beginner
342 Views

Hi, after checking my code, I find an error in assembling CSC matrix, and I`ve solved this problem, thx a lot.

By the way, if I try to compute the multiplication of two CSR matrix A and B with sparse_index_base_one both using mak_sparse_spmm to get another sparse matrix C, when I use mkl_sparse_?_export_csr, I find that the sparse_index_base is zero instead of one, is it correct or the function return the default internal data type rather than the input value?

Gennady_F_Intel
Moderator
342 Views

This looks like a problem. the output array should be indexed like the input arrays. Could you give us the example of this case?

wen_qiang_z_
Beginner
342 Views

Gennady F. (Intel) wrote:

This looks like a problem. the output array should be indexed like the input arrays. Could you give us the example of this case?

Hi,Gennedy

This case has appeared many times during my compute, and here is a easier way to actualize it:

1. Using mkl_sparse_?_create_csr to create two sparse matrix A and B with sparse_index_base_one

2.Using mkl_sparse_?_add to compute the sum of the two matrix and store the result as a sparse matrix C, or you can use mkl_sparse_spmm to compute the product of he two matrix

3. Export sparse matrix C and you will find out that the sparse_index_base is zero.

JWagner
New Contributor I
292 Views

Hello everyone,

I would like to chime in here, since I am facing pretty much the same issue. In my case I create a scaling matrix in coordinate format and try to convert it to csr format afterwards. This ends up with an error stating "Access violation writing location", as it seemed to be the case for wen_qiang_z_. Basically I am creating  the coo matrix like this:

const int valueAmount(13);

double coo_values[valueAmount] = { 1,2,3,4,5,6,7,8,9,10,11,12,13 };
int coo_RowIndx[valueAmount], coo_ColumnIndx[valueAmount] = { 0,1,2,3,4,5,6,7,8,9,10,11,12};

sparse_matrix_t B,C;

sparse_status_t stat = mkl_sparse_d_create_coo(&B, SPARSE_INDEX_BASE_ZERO, valueAmount, valueAmount, valueAmount, coo_RowIndx, coo_ColumnIndx, coo_values);

 

This ends with SPARSE_STATUS_SUCCESS and afterwards I want to transfer it:

mkl_sparse_convert_csr(B, SPARSE_OPERATION_TRANSPOSE, &C);

 

At this point I get the exception: "Exception thrown at 0x00007FFA98EA314F (mkl_sequential.1.dll) in Playground.exe: 0xC0000005: Access violation writing location 0x000001A551D3A330."

I would be glad about any hint about how to proceed.

Btw. the code is compile with Intel C++ 19.2 Compiler, using MKL 2021

Thanks in advance.

mecej4
Black Belt
284 Views

From your description, it seems to me that you have not entered any values into the array coo_RowIndx before passing the array to the MKL routines.

JWagner
New Contributor I
280 Views

Thanks, that was the issue.

Reply