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

Sparse Matrix Matrix Multiplication

Ferdous__S_M
初学者
969 次查看

I have a matrix A I want to perform the following operation in MKL,

C = A*AT 

Where A is a sparse matrix and A is the row l from h of A. I am currently computing The AT and then multiplying it using spmmd. Note that C is a dense matrix. But this approach wastes memory because I need to compute Aseparately.  Is there any specific function in MKL that I can use for this? 

0 项奖励
3 回复数
Kirill_V_Intel
969 次查看

Hello,

Have a look at mkl_sparse_?_syrkd, https://software.intel.com/en-us/mkl-developer-reference-c-mkl-sparse-syrkd. Isn't it what you're looking for?

Best,
Kirill

0 项奖励
Ferdous__S_M
初学者
969 次查看

Thanks. Not exactly. syrkd computes A*AT. But I do not want to compute it. What I need is a subset of the rows of A times the transpose of A. I do not see how I can use syrkd for achieving this.

0 项奖励
Kirill_V_Intel
969 次查看

I see, I didn't notice it. So, I guess then that h is relatively small, right? (if it was comparable with the size of the matrix you could use syrk and then throw away the part which is not needed).

If h is very small, you might consider conveting A(1:h,:) and the resulting matrix to a dense format, and make use of mkl_sparse_?_mm (and use an extra transposition of the result). Say, if A(1:h,:) = B (dense), you can write A(1:h,:)*A^T = B * A^T = (A * B^T)^T, so you can transpose B while converting A(1:h,:) to the dense format, compute the result using mm and then transpose the (skinny, dense) matrix product to get the final result (in the dense format).

You can also try to play around with CSR/CSC formats and transposition to avoid transposing the matrix A at the cost of transposing the other objects (similar to what I describe above) but I am not sure it will bring you a lot of benefits. 

Also, if you tell us more about your use case and why it happens to be something important ~ critical for performance, we can add it to the list of feature requests. 

Best,
Kirill

0 项奖励
回复