- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hello,

I would like to use MKL sparse blas in C++ for computing multithreaded sparse-dense matrix multiplication.

I would like to compute C = S * B, with S a sparse matrix in format coo or csc in 0-indexing and

C and B two dense matrix in ColMajor and 0-indexing format.

In all the mkl_?coomm or mkl_?cscmm functions it seems like we can only compute

this product with matrix in 0-indexing and Row major format...

Is there an effcient (fast) way to compute this product with Colmajor and 0-indexing format for dense matrix,

which means not using not using transposition for dense matrix.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

No it is not possible, unless you use the inspector-executor routines instead https://software.intel.com/en-us/articles/intel-math-kernel-library-inspector-executor-sparse-blas-routines.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

It may help if you (Nicolas) describe how you intend to use the result matrix C. With sparse matrices, operations are often more efficient when one does not attempt to store an intermediate matrix in the usual dense matrix form (two-dimensional array).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Ok thanks for your help,

qweasd q, it seems that the inspector-executor routines are not available on my MKL version...

I want to use MKL for interoperability with C++ Eigen library but what I see, if I use mkl_sparse_?_mm function for sparse matrix - dense matrix product, I have to use built-in type "sparse_matrix_t" for sparse matrix, I see you can construct a "sparse_matrix_t" from COO or CSC pointer but my question is : does it take a lot of time to build this "sparse_matrix_t" from COO or CSC pointer from a large sparse matrix ?

Does it duplicate the memory or just link the sparse_matrix_t directly to the pointer ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

to respond to mecej4,

I have a list of sparse matrix {S1,S2,...,Sn} and A a dense matrix and I want to compute C = Sn*Sn-1*...*S2*S1*A

the pseudo-code I use for that is :

for i=1 to n do C = Si*A;A=C; end for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

If matrices S_{1}, S_{2}, ..., all have the same sparseness pattern, or if you know in advance the sparseness pattern in the final product, some efficiency gains may be possible by doing suitable programming.

This routine for converting from COO to CSR/CSC may be useful: http://www.cs.umn.edu/~agupta/example/triplet2cs.c .

Another library worth considering for your purposes: http://people.uniroma2.it/salvatore.filippone/psblas/ .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Hi Nicolas,

As qweasd and mecej4 mentioned, there is some special optimization with such sparse matrix multiply loop. If you'd like to use MKL, You can use MKL 11.3 which have the functionality of the inspector-executor API for Sparse BLAS (SpMV 2).. and it also provides the optimization with the matrix sparsity pattern detect and reused.

mkl_sparse_optimize

Analyzes matrix structure and performs optimizations using the hints provided in the handle. Generally, specifying a higher number of expected operations allows for more aggressive and time consuming optimizations. Syntax Fortran: stat = mkl_sparse_optimize ( A ) C: sparse_status_t mkl_sparse_optimize( sparse_matrix_t A );

there is test example code in MKL install directory/ example folder. You can try them.

Best Regards

Ying

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page