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

Sparse matrix and dense matrix multiplication

Wei_W_
Beginner
1,043 Views

Hi,

Have a quick question to ask, I need to do A x B where A is a sparse matrix stored in CSR format, B is a symmetric dense matrix. Now I am using csrmm to compute the multiplication, but have to convert B into full dense matrix first, which doubles the memory for B. Is there any routine in MKL that can handles this?

Many thanks!

0 Kudos
4 Replies
Wei_W_
Beginner
1,043 Views

Any help would be appreciated, thanks!

0 Kudos
mecej4
Honored Contributor III
1,043 Views

Some questions that are relevant to the request:

  • How is the symmetric matrix B currently stored (before being converted to full, dense)?
  • What do you intend to do with A x B , after computing the product matrix?
  • How do you wish to store the product matrix?
0 Kudos
Wei_W_
Beginner
1,043 Views

Thanks for reply.

1. The B matrix is stored column wise, packed form (upper triangle) before converting to full dense matrix.

2. After computing AxB=C, I will do a for loop i=1:n, for each i, I need to do D_i x C, where D_i is also a sparse matrix. Here I use csrmm for sure since the dense C matrix is not symmetric.

3. The product matrix C is not symmetric, so just the regular way to store it, we use column major to store dense matrix in our code.

0 Kudos
Ying_H_Intel
Employee
1,043 Views

Hi Wei, 

It seems there is no good function can operate a spase matrix A*B (parcked upper triangle) form.  You may either convert B to dense matrix. Then use   mkl_?csrmm. Get sparse C matrix.  Then call  mkl_?csrmultd.  to compute D_i *C.

Or convert B to sparse matrix. use mkl_?csrmultd.  to compute C= A*B. Then mkl_?csrmm do D_i*C.  But if convert B to sparse matrix. it still need double memory. 

or call mkl_?csrgemv to compute ci=A*bi (B's colum vector). , then call csrmm do D_i*C. 

Best Regards,

Ying 

 

0 Kudos
Reply