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

Hello,

I have trouble getting mkl_?csrmm to output the correct answer to my program. I am wondering if I am using or inputting the correct parameters for what I want to do for the sparse routine. Any assistance would be greatly appreciated.

#include <stdio.h> #include <stdlib.h> #include "mkl.h" #define NNZ 8 #define M 6 #define N 2 #define K 3 /* This program tries to multiply : [5.0 0.0 1.0] [0.0 2.0 0.0] x [5.0 1.0] [0.0 3.0 0.0] [2.0 2.0] [0.0 0.0 1.0] [6.0 6.0] [1.0 0.0 0.0] [2.0 0.0 5.0] */ int main() { char transa = 'n'; MKL_INT m = M; MKL_INT n = N; MKL_INT k = K; float alpha = 1.0; char matdescra[5]; matdescra[0] = 'g'; matdescra[3] = 'f'; float val[NNZ] = { 5.0, 1.0, 2.0, 3.0, 1.0, 1.0, 2.0, 5.0 }; MKL_INT col[NNZ] = { 1, 3, 2, 2, 3, 1, 1, 3 }; MKL_INT ind[7] = { 1, 3, 4, 5, 6, 7, 9 }; float b= { { 5.0 , 1.0 },{ 2.0 , 2.0 },{ 6.0 , 6.0 } }; MKL_INT ldb = K; float beta = 0.0; float c = { { 0.0, 0.0 },{ 0.0, 0.0 },{ 0.0, 0.0 },{ 0.0, 0.0 },{ 0.0, 0.0 },{ 0.0, 0.0 } }; MKL_INT ldc = M; mkl_scsrmm(&transa, &m, &n, &k, &alpha, matdescra, val, col, ind, &(ind[1]), &(b[0][0]), &ldb, &beta, &(c[0][0]), &ldc); int i, j; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { printf("\n c[%d][%d] = %7.1f", i, j, c ); } } getchar(); return 0; }

Link Copied

2 Replies

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

I can see that problem here is in mix of parameters for 0-based and 1-based indexing.

If you're going to use 1-based indexing then you should change matrix layout to Column major, anyway I slightly modified your example to show correct usage for both cases.

Best regards,

Maria

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

Thank you so much Maria! These forums are very responsive and I appreciate the help that it gives.

Topic Options

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