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

sparse matrix multiplication mkl_?csrmultcsr example and limits

Kirk_D_
Novice
2,782 Views

Are there any examples of mkl_?csrmultcsr functions?  I have MKL 11.3 but have not found examples for these functions.  I am also interested in knowing the maximum dimension sizes for rows/cols of the matrices.

Thanks,
Kirk

0 Kudos
1 Solution
Ying_H_Intel
Employee
2,782 Views

 

Attached the sample. 

And you may find the mkl_?csrmultcsr sample in the forum , for example.    https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/639846 

Best Regards,
Ying 

View solution in original post

0 Kudos
5 Replies
Kirk_D_
Novice
2,782 Views

Note that I am using C/C++ and on Windows if that make any difference.

0 Kudos
Ying_H_Intel
Employee
2,782 Views

Hi Kirk, 

For the performance, i may recommend you to use the function mkl_sparse_spmm, it can calculate  sparce C =  sparse A* sparse B

sparse_status_t mkl_sparse_spmm (sparse_operation_t operation, const sparse_matrix_t A, const sparse_matrix_t B, sparse_matrix_t *C);

Include Files
• mkl_spblas.h
Description
The mkl_sparse_spmm routine performs a matrix-matrix operation:
C := op(A) *B
where A, B, and C are sparse matrices.

I update one c sample and the sample will be in MKL install folder /example/.  

Best Regards,

Ying 

0 Kudos
Ying_H_Intel
Employee
2,783 Views

 

Attached the sample. 

And you may find the mkl_?csrmultcsr sample in the forum , for example.    https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/639846 

Best Regards,
Ying 

0 Kudos
Kirk_D_
Novice
2,782 Views

Thank you for the sample, I was able to figure out what I functions calls I needed. 

I have one question regarding the output however.  One of the result matrix items from the mkl_sparse_d_create_csr, mkl_sparse_spmm, and mkl_sparse_d_export_csr calls is coming out to a value of 0, and I would expect it NOT to be included in the result matrix in csr format, but it is. 

When looking at the matrix multiplication "by-hand" in dense matrix format, the cell in question should be calculated by (3*-2)+(9*0)+(0*0)+(0*5)+(0*9)+(3*2), which yields 0.  Any idea why this zero would be included in the resulting csr matrix?

Thanks,

Kirk

 

0 Kudos
Alexander_K_Intel2
2,782 Views

Hi Kirk,

The reason of including "zero" element in resulted structure is the fact that structure and values calculated in different part of code to achieve better performance and it is hard to remove zero elements from structure after calculation. 

Thanks,

Alex

0 Kudos
Reply