Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Sparse BLAS - sparse_dense matrix multiplication with zero indexing and colmajor matrix

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

Nicolas_B_3

Beginner

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

10-12-2015
02:16 AM

124 Views

Sparse BLAS - sparse_dense matrix multiplication with zero indexing and colmajor matrix

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

6 Replies

asd__asdqwe

Beginner

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

10-12-2015
08:28 AM

124 Views

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.

mecej4

Black Belt

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

10-12-2015
09:10 AM

124 Views

Nicolas_B_3

Beginner

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

10-15-2015
01:21 AM

124 Views

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 ?

Nicolas_B_3

Beginner

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

10-15-2015
01:47 AM

124 Views

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

mecej4

Black Belt

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

10-16-2015
04:48 AM

124 Views

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/ .

Ying_H_Intel

Employee

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

10-18-2015
10:45 PM

124 Views

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

For more complete information about compiler optimizations, see our Optimization Notice.