Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- sparse matrix dense matrix multiplication

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

utab

Beginner

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

07-27-2012
04:20 AM

39 Views

sparse matrix dense matrix multiplication

For my Krylov subspace basis build up, I am doing some sparse matrix - dense matrix multiplications. That is fine. I use mkl_dcsrmm for this. But the question now is I am keeping my Krylov vectors in a

std::vector

conceptually, the vectors are the columns of my dense matrix. However, the above interface is considering all the matrices in row major order, is there a way to change this. Since I keep my basis in an array of arrays, I should somehow make it interpreted colum-wise. Is there a work around for this? Or both matrix ordering should be the same when using the routine so one could not be row major(the sparse matrix) and the dense matrix, column major? This is far more efficient and easy to use if there is a work-around for this task.

For instance for the below simple code, I would like b to be interpreted column wise not row-wise while a is still row-wise.

int main()

{

double a[] = {1.e0,2.e0,3.e0};

int ia[] = {0,1,2,3};

int ja[] = {0,1,2};

double b[] = {1.e0,4.e0,2.e0,5.e0,3.e0,6.e0};

double c[] = {0,0,0,0,0,0};

MKL_INT m = 3;

MKL_INT k= 3;

MKL_INT n = 2;

double alpha = 1.0;

double beta = 0.0;

//

char matdescra[6];

matdescra[0]= 'g';

matdescra[1]= 'l';

matdescra[2]= 'u';

matdescra[3]= 'c';

char transa = 'N';

mkl_dcsrmm(&transa,

&m, &n, &k,

&alpha,

matdescra,

a, ja, ia,

ia+1, b,

&n, &beta, c, &n);

//

for(int z=0;z<6;z++)

std::cout << c

return 0;

}

Link Copied

3 Replies

Henrik_A_

Beginner

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

07-31-2012
02:54 AM

39 Views

Peter_B_9

Beginner

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

08-29-2013
05:56 AM

39 Views

It appears that there's an undocumented "feature" in the mkl_dcsrmm and mkl_scsrmm family of functions. If the sparse matrix uses zero-based indexing, MKL treates the dense matrices as row-major. If the sparse matrix uses one-based indexing MKL treats the desnce matrices as column-major. If you wish to use column-major dense matrices you must use one-based indexing for the CSR matrix.

See http://software.intel.com/en-us/forums/topic/456104#comment-1749818

asd__asdqwe

Beginner

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

08-30-2013
01:24 AM

39 Views

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