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

"sparse_status_not_initalized" error when initalizing zero matrix

may_ka
Beginner
611 Views

Hi,

 

when trying to use "mkl_sparse_d_create_csr" on a sparse matrix which contains only zeros, I get the error "sparse_status_not_initalized".

 

The structure of the matrix is:

 

  • size of rowindex array is n_rows + 1
  • size of column index array is zero
  • size of value array is zero

 

Is this a bug or wanted?

 

From an application perspective it is undesirable!!

 

Cheers

0 Kudos
5 Replies
VidyalathaB_Intel
Moderator
583 Views

Hi Karl,

 

Thanks for reaching out to us.

 

The error "sparse_status_not_initalized" indicates that the routine encountered an empty handle or matrix array as per the MKL documentation https://www.intel.com/content/www/us/en/develop/documentation/onemkl-developer-reference-c/top/blas-and-sparse-blas-routines/inspector-executor-sparse-blas-routines/matrix-manipulation-routines/mkl-sparse-create-csr.html

>>From an application perspective it is undesirable!!

It would be great if you let us know your use case in which you are using a sparse matrix with only zeros along with a sample reproducer so that we can test it from our end as well.

 

Regards,

Vidya.

 

0 Kudos
VidyalathaB_Intel
Moderator
544 Views

Hi Karl,


As we haven't heard back from you, could you please provide us with an update regarding the issue?


Regards,

Vidya.


0 Kudos
VidyalathaB_Intel
Moderator
520 Views

Hi Karl,


As we haven't heard back from you we are closing this thread. Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.


Regards,

Vidya.


0 Kudos
Spencer_P_Intel
Employee
468 Views

Hi may_ka,

 

This is a tricky case to handle well in C/C++.  The main reason it is tricky, is that an array of length zero is the same thing as an array that is uninitialized (ie NULL) when dealing with allocated pointers.  We have checks in our function that initialized arrays are being passed in to be set and the current assumption is that if the array is null, then it was a mistake (unintentional) to pass it in. 

I wonder what application should support an empty sparse matrix (ie a zero matrix) ?  Can you tell me more about where this could come up and why it should be handled at mkl level instead of application level ?

A workaround to create a functional zero matrix could be to create an array of length 1 or anything larger than 0 (so that the allocator succeeds in allocating space) for each of your colind and values arrays (initialize them to whatever you like), and then if rowptr is initialized to all 0s, those other arrays will never be used, but it will function in mkl calls as you expect (even if it will check all the rowptr values, and so is an O(nrows) operation for anything you want to do). 

Hope this helps, but look forward to hearing more about when this comes up

 

Best,

Spencer

0 Kudos
Kirill_V_Intel
Employee
462 Views

Hi @Spencer_P_Intel ,

 

I think the use case is actually valid and the lack of support in MKL is an artificial limitation (checks might affect performance of course but will it really?) rather than a necessity.

E.g., imagine a matrix-based algorithm which is written as:

C = 0

for i in 1, 2 ...N

  C += A_i*B_i

or anything like that.
Alternatively, a zero matrix can appear in runtime with a non-analytical expression for the nnz so that the user might not know exactly that the matrix to be created has zero elements.

Of course, it would be an illegal matrix if rowptr is NULL but this is not the case as I understand.

 

Best,
Kirill

0 Kudos
Reply