Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Thomas_D_
Beginner
331 Views

transpose matrix stored in CSR format using MKL

All,

I have some legacy parallel code that uses CSR format to store a very large, sparse matrix. In making some additions to the code, I have the need to transpose the matrix, storing the transpose in CSR format as well.

Is there a routine in the MKL that would help me do this? I thought of using a BLAS routine to repeatedly multiply column vectors with ones in successive locations by the matrix, and accumulate the results. Is there a better way?

Thanks,

Tom

0 Kudos
6 Replies
mecej4
Black Belt
331 Views

Here is an idea for you to evaluate -- it may not be as efficient as writing your own code to do the transformation, but it is unlikely to lead to a bottleneck.

Note that the CSR representation of a matrix A is identical to the CSC representation of AT. Therefore, code using the relevant version of mkl_?csrcsc may be the easiest to implement.

Alternatively, convert the CSR representation to a COO representation, say (IC, JC, VC). The COO representation of the transpose is (JC,IC,VC). Convert this COO representation to a CSR representation of the transposed matrix.

Which option to use depends on what other transformations you need to perform, if any, in addition to transposing.

Routines for doing the conversions indicated are provided in MKL.

 

Thomas_D_
Beginner
331 Views

Thanks, that look like a promising approach!

Regards,

Tom

Li__Yapeng
Beginner
331 Views

The function of mkl_sparse_?_add can perform what you want.

Gennady_F_Intel
Moderator
331 Views

good catch, thanks, but Tom, please take into account this functionality was added since MKL v.11.3 and i am not sure whch version of MKL do you use right now. The latest version of MKL is 2019 ( release, Aug 2018)

Tibaldi__Alberto
Beginner
331 Views

Hi,

Another solution is to use MKL_SPARSE_CONVERT_CSR. Even if the matrix is in CSR format, if you perform (RACSR in my example is a matrix already stored in CSR format),

    mkl_status = MKL_SPARSE_CONVERT_CSR(RACSR, SPARSE_OPERATION_TRANSPOSE, RACSR)

after this command, RACSR is transposed.

Best Regards,

Alberto

Gennady_F_Intel
Moderator
331 Views

just for info: the current ( MKL 2020) status of mkl_sparse_?_add routine: this routine is only supported for sparse matrices in CSR and BSR formats. It is not supported for COO or CSC formats.   

 

Reply