- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to take the product of a sparse matrix with a dense matrix and store the result in a new matrix
C = A * B;
Where C is a dense 5x3 matrix
Where A is a sparse 5x7 matrix
Where B is a dense 7x3 matrix
mkl_dcoomm implements C = alpha*A*B + beta*C
In my call to mkl_dcoomm if I set beta = 1.0 the program runs without a segfault (correctly computing the result). When I set beta to any other value the program terminates with a segfault (after correctly computing the result). The segfault occurs at termination but if I run valgrind it occurs after a violating write in mkl_dcoomm. The documentation on the dimensions of B and C is cyclic and horrible. So it may be possible that B and C need to be larger to accommodate buffer room. If this is the case please let me know.
The code that I am using is appended below. In my application the value of C will not always be zeros and so I need beta =0. Any help with this would be greatly appreciated as this is really annoying and yet should be very simple.
#include "mkl_types.h"
#include "mkl_spblas.h"
#include "mkl_cblas.h"
#include "mkl_vml.h"
#include "mkl_bp.hpp"
using namespace std;
int main(int argc, char** argv) {
MKL_INT row_ind[12] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
MKL_INT col_ind[12] = {0, 0, 2, 2, 3, 4, 0, 1, 4, 1, 2, 3};
double a_val[12] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double x_val[7][3] = {{ 10, 7, 13 },
{ 7, 4, 1 },
{ 8, 7, 12 },
{ 4, 9, 12 },
{ 6, 9, 11 },
{ 13, 6, 2 },
{ 8, 5, 4 }};
MKL_INT A_r = 5;
MKL_INT A_c = 7;
MKL_INT A_nzs = 12;
MKL_INT* A_rind = new MKL_INT[A_nzs];
for(size_t i = 0; i MKL_INT* A_cind = new MKL_INT[A_nzs];
for(size_t i = 0; i double* A_val = new double[A_nzs];
for(size_t i = 0; i MKL_INT B_r = 7;
MKL_INT B_c = 3;
double* B_val = new double[B_r * B_c];
size_t ind = 0;
for(size_t r = 0; r for(size_t c = 0; c B_val[ind++] = x_val;
MKL_INT C_r = 5;
MKL_INT C_c = 3;
double* C_val = new double[C_r * C_c];
for(MKL_INT i=0; i cout char trans = 'n';
double alpha = 1.0;
double beta = 0.0;
char metadata[6];
metadata[0] = 'g'; metadata[1] = 'l';
metadata[2] = 'n'; metadata[3] = 'c';
metadata[4] = ' '; metadata[5] = ' ';
mkl_dcoomm(&trans, &A_r, &B_c, &A_c,
a, metadata, A_val, A_rind, A_cind, &A_nzs,
B_val, &B_c, ,
C_val, &C_c);
return EXIT_SUCCESS;
}
C = A * B;
Where C is a dense 5x3 matrix
Where A is a sparse 5x7 matrix
Where B is a dense 7x3 matrix
mkl_dcoomm implements C = alpha*A*B + beta*C
In my call to mkl_dcoomm if I set beta = 1.0 the program runs without a segfault (correctly computing the result). When I set beta to any other value the program terminates with a segfault (after correctly computing the result). The segfault occurs at termination but if I run valgrind it occurs after a violating write in mkl_dcoomm. The documentation on the dimensions of B and C is cyclic and horrible. So it may be possible that B and C need to be larger to accommodate buffer room. If this is the case please let me know.
The code that I am using is appended below. In my application the value of C will not always be zeros and so I need beta =0. Any help with this would be greatly appreciated as this is really annoying and yet should be very simple.
#include "mkl_types.h"
#include "mkl_spblas.h"
#include "mkl_cblas.h"
#include "mkl_vml.h"
#include "mkl_bp.hpp"
using namespace std;
int main(int argc, char** argv) {
MKL_INT row_ind[12] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4};
MKL_INT col_ind[12] = {0, 0, 2, 2, 3, 4, 0, 1, 4, 1, 2, 3};
double a_val[12] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
double x_val[7][3] = {{ 10, 7, 13 },
{ 7, 4, 1 },
{ 8, 7, 12 },
{ 4, 9, 12 },
{ 6, 9, 11 },
{ 13, 6, 2 },
{ 8, 5, 4 }};
MKL_INT A_r = 5;
MKL_INT A_c = 7;
MKL_INT A_nzs = 12;
MKL_INT* A_rind = new MKL_INT[A_nzs];
for(size_t i = 0; i MKL_INT* A_cind = new MKL_INT[A_nzs];
for(size_t i = 0; i double* A_val = new double[A_nzs];
for(size_t i = 0; i MKL_INT B_r = 7;
MKL_INT B_c = 3;
double* B_val = new double[B_r * B_c];
size_t ind = 0;
for(size_t r = 0; r for(size_t c = 0; c B_val[ind++] = x_val
MKL_INT C_r = 5;
MKL_INT C_c = 3;
double* C_val = new double[C_r * C_c];
for(MKL_INT i=0; i cout char trans = 'n';
double alpha = 1.0;
double beta = 0.0;
char metadata[6];
metadata[0] = 'g'; metadata[1] = 'l';
metadata[2] = 'n'; metadata[3] = 'c';
metadata[4] = ' '; metadata[5] = ' ';
mkl_dcoomm(&trans, &A_r, &B_c, &A_c,
a, metadata, A_val, A_rind, A_cind, &A_nzs,
B_val, &B_c, ,
C_val, &C_c);
return EXIT_SUCCESS;
}
Link Copied
0 Replies

Reply
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