<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic calling mkl_dcoomm from C memory issues in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/calling-mkl-dcoomm-from-C-memory-issues/m-p/884988#M9972</link>
    <description>I am trying to take the product of a sparse matrix with a dense matrix and store the result in a new matrix
&lt;BR /&gt;
&lt;BR /&gt;C = A * B;
&lt;BR /&gt;
&lt;BR /&gt;Where C is a dense 5x3 matrix
&lt;BR /&gt;Where A is a sparse 5x7 matrix
&lt;BR /&gt;Where B is a dense 7x3 matrix
&lt;BR /&gt;
&lt;BR /&gt;mkl_dcoomm implements  C = alpha*A*B + beta*C
&lt;BR /&gt;
&lt;BR /&gt;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.
&lt;BR /&gt;
&lt;BR /&gt;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.
&lt;BR /&gt;
&lt;BR /&gt;#include "mkl_types.h"
&lt;BR /&gt;#include "mkl_spblas.h"
&lt;BR /&gt;#include "mkl_cblas.h"
&lt;BR /&gt;#include "mkl_vml.h"
&lt;BR /&gt;#include "mkl_bp.hpp"
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;using namespace std;
&lt;BR /&gt;
&lt;BR /&gt;int main(int argc, char** argv) {
&lt;BR /&gt;  MKL_INT row_ind[12] = {0, 1, 1,  2, 2, 2,  3, 3, 3,  4, 4, 4};
&lt;BR /&gt;  MKL_INT col_ind[12] = {0, 0, 2,  2, 3, 4,  0, 1, 4,  1, 2, 3};
&lt;BR /&gt;  double a_val[12]   =  {1, 1, 1,  1, 1, 1,  1, 1, 1,  1, 1, 1};
&lt;BR /&gt;  double x_val[7][3] = {{ 10,  7,  13 },
&lt;BR /&gt;                        {  7,  4,   1 },
&lt;BR /&gt;                        {  8,  7,  12 },
&lt;BR /&gt;                        {  4,  9,  12 },
&lt;BR /&gt;                        {  6,  9,  11 },
&lt;BR /&gt;                        { 13,  6,   2 },
&lt;BR /&gt;                        {  8,  5,   4 }};
&lt;BR /&gt;  MKL_INT A_r = 5;
&lt;BR /&gt;  MKL_INT A_c = 7;
&lt;BR /&gt;  MKL_INT A_nzs = 12;
&lt;BR /&gt;  MKL_INT* A_rind = new MKL_INT[A_nzs];
&lt;BR /&gt;  for(size_t i = 0; i   MKL_INT* A_cind = new MKL_INT[A_nzs];
&lt;BR /&gt;  for(size_t i = 0; i   double* A_val = new double[A_nzs];
&lt;BR /&gt;  for(size_t i = 0; i   MKL_INT B_r = 7;
&lt;BR /&gt;  MKL_INT B_c = 3;
&lt;BR /&gt;  double* B_val = new double[B_r * B_c];
&lt;BR /&gt;  
&lt;BR /&gt;  size_t ind = 0;
&lt;BR /&gt;  for(size_t r = 0; r     for(size_t c = 0; c       B_val[ind++] = x_val&lt;R&gt;&lt;C&gt;;
&lt;BR /&gt;  
&lt;BR /&gt;  MKL_INT C_r = 5;
&lt;BR /&gt;  MKL_INT C_c = 3;
&lt;BR /&gt;  double* C_val = new double[C_r * C_c];
&lt;BR /&gt;  for(MKL_INT i=0; i   cout   char trans = 'n';
&lt;BR /&gt;  double alpha = 1.0;
&lt;BR /&gt;  double beta = 0.0;
&lt;BR /&gt;  char metadata[6];
&lt;BR /&gt;  metadata[0] = 'g'; metadata[1] = 'l';
&lt;BR /&gt;  metadata[2] = 'n'; metadata[3] = 'c';
&lt;BR /&gt;  metadata[4] = ' '; metadata[5] = ' ';
&lt;BR /&gt;  mkl_dcoomm(&amp;amp;trans, &amp;amp;A_r, &amp;amp;B_c, &amp;amp;A_c,
&lt;BR /&gt;             a, metadata, A_val, A_rind, A_cind, &amp;amp;A_nzs,
&lt;BR /&gt;             B_val, &amp;amp;B_c, ,
&lt;BR /&gt;             C_val, &amp;amp;C_c);
&lt;BR /&gt;
&lt;BR /&gt;  return EXIT_SUCCESS;
&lt;BR /&gt;}&lt;/C&gt;&lt;/R&gt;</description>
    <pubDate>Wed, 21 May 2008 03:15:54 GMT</pubDate>
    <dc:creator>jegonzal</dc:creator>
    <dc:date>2008-05-21T03:15:54Z</dc:date>
    <item>
      <title>calling mkl_dcoomm from C memory issues</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/calling-mkl-dcoomm-from-C-memory-issues/m-p/884988#M9972</link>
      <description>I am trying to take the product of a sparse matrix with a dense matrix and store the result in a new matrix
&lt;BR /&gt;
&lt;BR /&gt;C = A * B;
&lt;BR /&gt;
&lt;BR /&gt;Where C is a dense 5x3 matrix
&lt;BR /&gt;Where A is a sparse 5x7 matrix
&lt;BR /&gt;Where B is a dense 7x3 matrix
&lt;BR /&gt;
&lt;BR /&gt;mkl_dcoomm implements  C = alpha*A*B + beta*C
&lt;BR /&gt;
&lt;BR /&gt;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.
&lt;BR /&gt;
&lt;BR /&gt;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.
&lt;BR /&gt;
&lt;BR /&gt;#include "mkl_types.h"
&lt;BR /&gt;#include "mkl_spblas.h"
&lt;BR /&gt;#include "mkl_cblas.h"
&lt;BR /&gt;#include "mkl_vml.h"
&lt;BR /&gt;#include "mkl_bp.hpp"
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;using namespace std;
&lt;BR /&gt;
&lt;BR /&gt;int main(int argc, char** argv) {
&lt;BR /&gt;  MKL_INT row_ind[12] = {0, 1, 1,  2, 2, 2,  3, 3, 3,  4, 4, 4};
&lt;BR /&gt;  MKL_INT col_ind[12] = {0, 0, 2,  2, 3, 4,  0, 1, 4,  1, 2, 3};
&lt;BR /&gt;  double a_val[12]   =  {1, 1, 1,  1, 1, 1,  1, 1, 1,  1, 1, 1};
&lt;BR /&gt;  double x_val[7][3] = {{ 10,  7,  13 },
&lt;BR /&gt;                        {  7,  4,   1 },
&lt;BR /&gt;                        {  8,  7,  12 },
&lt;BR /&gt;                        {  4,  9,  12 },
&lt;BR /&gt;                        {  6,  9,  11 },
&lt;BR /&gt;                        { 13,  6,   2 },
&lt;BR /&gt;                        {  8,  5,   4 }};
&lt;BR /&gt;  MKL_INT A_r = 5;
&lt;BR /&gt;  MKL_INT A_c = 7;
&lt;BR /&gt;  MKL_INT A_nzs = 12;
&lt;BR /&gt;  MKL_INT* A_rind = new MKL_INT[A_nzs];
&lt;BR /&gt;  for(size_t i = 0; i   MKL_INT* A_cind = new MKL_INT[A_nzs];
&lt;BR /&gt;  for(size_t i = 0; i   double* A_val = new double[A_nzs];
&lt;BR /&gt;  for(size_t i = 0; i   MKL_INT B_r = 7;
&lt;BR /&gt;  MKL_INT B_c = 3;
&lt;BR /&gt;  double* B_val = new double[B_r * B_c];
&lt;BR /&gt;  
&lt;BR /&gt;  size_t ind = 0;
&lt;BR /&gt;  for(size_t r = 0; r     for(size_t c = 0; c       B_val[ind++] = x_val&lt;R&gt;&lt;C&gt;;
&lt;BR /&gt;  
&lt;BR /&gt;  MKL_INT C_r = 5;
&lt;BR /&gt;  MKL_INT C_c = 3;
&lt;BR /&gt;  double* C_val = new double[C_r * C_c];
&lt;BR /&gt;  for(MKL_INT i=0; i   cout   char trans = 'n';
&lt;BR /&gt;  double alpha = 1.0;
&lt;BR /&gt;  double beta = 0.0;
&lt;BR /&gt;  char metadata[6];
&lt;BR /&gt;  metadata[0] = 'g'; metadata[1] = 'l';
&lt;BR /&gt;  metadata[2] = 'n'; metadata[3] = 'c';
&lt;BR /&gt;  metadata[4] = ' '; metadata[5] = ' ';
&lt;BR /&gt;  mkl_dcoomm(&amp;amp;trans, &amp;amp;A_r, &amp;amp;B_c, &amp;amp;A_c,
&lt;BR /&gt;             a, metadata, A_val, A_rind, A_cind, &amp;amp;A_nzs,
&lt;BR /&gt;             B_val, &amp;amp;B_c, ,
&lt;BR /&gt;             C_val, &amp;amp;C_c);
&lt;BR /&gt;
&lt;BR /&gt;  return EXIT_SUCCESS;
&lt;BR /&gt;}&lt;/C&gt;&lt;/R&gt;</description>
      <pubDate>Wed, 21 May 2008 03:15:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/calling-mkl-dcoomm-from-C-memory-issues/m-p/884988#M9972</guid>
      <dc:creator>jegonzal</dc:creator>
      <dc:date>2008-05-21T03:15:54Z</dc:date>
    </item>
  </channel>
</rss>

