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

Getting the status as SPARSE_STATUS_NOT_INITIALIZED when trying to export after spmm

AmmuMadhu
Beginner
852 Views

Dear Team,

I am using 2022.2.1 version mkl_rt.2.dll to perform a sparse matrix multiplication followed by export of sparse handle to store the results in variables via C#.

My matrix is 9157 x 9157 csr matrix. I am trying to multiply with itself.

 

Sparse SPMM definition (in NativeMethods.cs):

[DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern SPARSE_STATUS mkl_sparse_spmm(SPARSE_OPERATION transA, IntPtr A, IntPtr B, out IntPtr C);

 

Invocation:

 

var retval = NativeMethods.mkl_sparse_spmm(NativeMethods.SPARSE_OPERATION.SPARSE_OPERATION_NON_TRANSPOSE, this.sparseHandle, right.sparseHandle, out IntPtr outsparsehandle);

 

This operation is successful and also during debugging i am able to see that outsparsehandle is updated with new value.

 

However, when I try to export from handle, i am getting Not Initialized error.

 

Definition:

[DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)]
internal static extern SPARSE_STATUS mkl_sparse_s_export_csr(IntPtr C, SPARSE_INDEX idx, int rows, int cols, int[] rows_start, int[] rows_end, int[] col_indx, float[] values);

 

Invocation:

retval = NativeMethods.mkl_sparse_s_export_csr(output.sparseHandle, index, row_cnt, col_cnt, rowstarts, rowends, columnindices, values);

 

Kindly help me in identifying where I am going wrong. Your help is greatly appreciated.

0 Kudos
5 Replies
AmmuMadhu
Beginner
778 Views

Team, am able to run the code successfully. However only rows and cols are updated through output handle. Rest are not updated with address. The highlighted variables in red are not populated correctly.


var c = new mkllib.SparseMatrix();
var ____arg1 = c.__Instance;
var outputhandle = new System.IntPtr(&____arg1);
//var retval = NativeMethods.mkl_sparse_sp2m(NativeMethods.SPARSE_OPERATION.SPARSE_OPERATION_NON_TRANSPOSE, descA, this.sparseHandle, NativeMethods.SPARSE_OPERATION.SPARSE_OPERATION_NON_TRANSPOSE, descB, right.sparseHandle, NativeMethods.SPARSE_MATRIX_REQUEST.SPARSE_STAGE_FULL_MULT, out output.sparseHandle);
var retval = NativeMethods.mkl_sparse_spmm(NativeMethods.SPARSE_OPERATION.SPARSE_OPERATION_NON_TRANSPOSE, this.sparseHandle, right.sparseHandle, out outputhandle);

if (retval != NativeMethods.SPARSE_STATUS.SPARSE_STATUS_SUCCESS)
{
throw new Exception($"Failed to multiply MKL spblas sparse matrix handle: {retval}");
}
else
{
try
{
mkllib.SparseStatusT retval1;
IntelMKL.ILP64.SparseIndexBaseT index = new IntelMKL.ILP64.SparseIndexBaseT();
IntelMKL.ILP64.SparseIndexBaseT* idx = &index;
int rows, cols;
int* row_starts, row_ends, Col_Indices;
float* values;
retval1 = IntelMKL.ILP64.SpBlas.__Internal.MklSparseSExportCsr(outputhandle, idx, &rows, &cols, &row_starts, &row_ends, &Col_Indices, &values);
Console.WriteLine(row_starts[22]);
Console.WriteLine(values[12]);
Console.WriteLine(Col_Indices[21]);



}
finally
{ }

0 Kudos
AmmuMadhu
Beginner
778 Views

Your prompt help would be greatly appreciated.

0 Kudos
ShanmukhS_Intel
Moderator
757 Views

Hi Madhusudhanan,


Thanks for posting on Intel Communities.


We would like to request you share a sample reproducer/project file and steps(if any) so that we could investigate your issue and help you assist with that.


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
728 Views

Hi Madhusudhan,


A gentle reminder:

We have not heard back from you. Could you please get back to us with the earlier-mentioned details so that we could look into your issue further?


Best Regards,

Shanmukh.SS


0 Kudos
ShanmukhS_Intel
Moderator
711 Views

Hi Madhusudhan,


We assume that your issue is resolved. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Best Regards,

Shanmukh.SS


0 Kudos
Reply