<?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 csrmultcsr  confusing calling API, not matching documentation in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805714#M3400</link>
    <description>I am struggling to use CSRMULTCSR ( sparse matrix-matrix multiplication)&lt;BR /&gt;&lt;BR /&gt;I have my own reference version of Sparse matrix-matrix multiplication for CSR running on CPU. I would like to test it against MKL and I have hard time to match MKL when m,n,k are not equal.&lt;BR /&gt;&lt;BR /&gt;The documentation and the MKL header file do not even have the same variable convention and their m,n,k mapping do not follow the convention.&lt;BR /&gt;&lt;BR /&gt;MKL Documentation:&lt;BR /&gt;mkl_dcsrmultcsr(&amp;amp;trans, &amp;amp;request, &amp;amp;sort, &amp;amp;m, &amp;amp;n, &amp;amp;k, a, ja, ia, b, jb, ib, c, jc, ic, &amp;amp;nzmax, &amp;amp;info);&lt;BR /&gt;m INTEGER. Number of rows of the matrix A.&lt;BR /&gt;n INTEGER. Number of columns of the matrix A.&lt;BR /&gt;k INTEGER. Number of columns of the matrix B.&lt;BR /&gt;&lt;BR /&gt;Header file :&lt;BR /&gt;void mkl_dcsrmultcsr(char *transa, MKL_INT *job, MKL_INT *sort, MKL_INT *n, MKL_INT *k, MKL_INT *m, double *a, MKL_INT *ja, MKL_INT *ia, double *b, MKL_INT *jb, MKL_INT *ib, double *c, MKL_INT *jc, MKL_INT *ic, MKL_INT *nnzmax, MKL_INT *ierr);&lt;BR /&gt;&lt;BR /&gt;But for example CSRMM follows the normal convention m,n,k in that order where m= rows of A, n = cols of B, k = cols of A,rows of B :&lt;BR /&gt;&lt;BR /&gt;void mkl_dcsrmm(char *transa, MKL_INT *m, MKL_INT *n, MKL_INT *k, double *alpha, char *matdescra, double *val, MKL_INT *indx, MKL_INT *pntrb, MKL_INT *pntre, double *b, MKL_INT *ldb, double *beta, double *c, MKL_INT *ldc);&lt;BR /&gt;&lt;BR /&gt;How should I call mkl_dcsrmultcsr ?&lt;BR /&gt;What do m,n,k represent?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 26 Oct 2011 00:14:01 GMT</pubDate>
    <dc:creator>philvdm</dc:creator>
    <dc:date>2011-10-26T00:14:01Z</dc:date>
    <item>
      <title>csrmultcsr  confusing calling API, not matching documentation</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805714#M3400</link>
      <description>I am struggling to use CSRMULTCSR ( sparse matrix-matrix multiplication)&lt;BR /&gt;&lt;BR /&gt;I have my own reference version of Sparse matrix-matrix multiplication for CSR running on CPU. I would like to test it against MKL and I have hard time to match MKL when m,n,k are not equal.&lt;BR /&gt;&lt;BR /&gt;The documentation and the MKL header file do not even have the same variable convention and their m,n,k mapping do not follow the convention.&lt;BR /&gt;&lt;BR /&gt;MKL Documentation:&lt;BR /&gt;mkl_dcsrmultcsr(&amp;amp;trans, &amp;amp;request, &amp;amp;sort, &amp;amp;m, &amp;amp;n, &amp;amp;k, a, ja, ia, b, jb, ib, c, jc, ic, &amp;amp;nzmax, &amp;amp;info);&lt;BR /&gt;m INTEGER. Number of rows of the matrix A.&lt;BR /&gt;n INTEGER. Number of columns of the matrix A.&lt;BR /&gt;k INTEGER. Number of columns of the matrix B.&lt;BR /&gt;&lt;BR /&gt;Header file :&lt;BR /&gt;void mkl_dcsrmultcsr(char *transa, MKL_INT *job, MKL_INT *sort, MKL_INT *n, MKL_INT *k, MKL_INT *m, double *a, MKL_INT *ja, MKL_INT *ia, double *b, MKL_INT *jb, MKL_INT *ib, double *c, MKL_INT *jc, MKL_INT *ic, MKL_INT *nnzmax, MKL_INT *ierr);&lt;BR /&gt;&lt;BR /&gt;But for example CSRMM follows the normal convention m,n,k in that order where m= rows of A, n = cols of B, k = cols of A,rows of B :&lt;BR /&gt;&lt;BR /&gt;void mkl_dcsrmm(char *transa, MKL_INT *m, MKL_INT *n, MKL_INT *k, double *alpha, char *matdescra, double *val, MKL_INT *indx, MKL_INT *pntrb, MKL_INT *pntre, double *b, MKL_INT *ldb, double *beta, double *c, MKL_INT *ldc);&lt;BR /&gt;&lt;BR /&gt;How should I call mkl_dcsrmultcsr ?&lt;BR /&gt;What do m,n,k represent?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Oct 2011 00:14:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805714#M3400</guid>
      <dc:creator>philvdm</dc:creator>
      <dc:date>2011-10-26T00:14:01Z</dc:date>
    </item>
    <item>
      <title>csrmultcsr  confusing calling API, not matching documentation</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805715#M3401</link>
      <description>&lt;P&gt;Hello, &lt;BR /&gt;&lt;BR /&gt;thanks for the asking. Yes, it seemsthat the documentaion and declaration in header file should be corrected. we will fix it in the future release. &lt;BR /&gt;&lt;BR /&gt;If use it, you may read it as Amxn* Bnxk.call it based on it's discription&lt;BR /&gt;&lt;BR /&gt;mkl_dcsrmultcsr(&amp;amp;trans, &amp;amp;request, &amp;amp;sort, &amp;amp;m, &amp;amp;n, &amp;amp;k, a, ja, ia, b, jb, ib, c, jc, ic, &amp;amp;nzmax, &amp;amp;info);&lt;BR /&gt;m INTEGER. Number of rows of the matrix A.&lt;BR /&gt;n INTEGER. Number of columns of the matrix A.&lt;BR /&gt;k INTEGER. Number of columns of the matrix B&lt;BR /&gt;&lt;BR /&gt;And thereisa sample given in the directory /mkl/examples/spblas/source/dcsr_multiplication.f&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ying H.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Oct 2011 07:42:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805715#M3401</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2011-10-26T07:42:57Z</dc:date>
    </item>
    <item>
      <title>csrmultcsr  confusing calling API, not matching documentation</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805716#M3402</link>
      <description>When m,n,k are NOT equal, it seems that there is some problem.&lt;BR /&gt;The example given in /mkl/examples/spblas/source is not helping because n=m=k&lt;BR /&gt;&lt;BR /&gt;With m=3, n=4,k=5, I tried all the 6 combinations. 4 seg faults, 2 do not match my reference code with 3 errors.&lt;BR /&gt;&lt;BR /&gt;I have even a smaller example using 2 small dense matrix in csr format&lt;BR /&gt;&lt;BR /&gt;matrix A&lt;BR /&gt;RowPtr :1 3 5 &lt;BR /&gt;ColId :1 2 1 2 &lt;BR /&gt;Dense representation :&lt;BR /&gt;1.00, 2.00, &lt;BR /&gt;3.00, 4.00, &lt;BR /&gt;&lt;BR /&gt;matrix B&lt;BR /&gt;RowPtr :1 4 7 &lt;BR /&gt;ColId :1 2 3 1 2 3 &lt;BR /&gt;Dense repesentation&lt;BR /&gt;1.00, 2.00, 3.00, &lt;BR /&gt;4.00, 5.00, 6.00, &lt;BR /&gt;&lt;BR /&gt;My reference code gives:&lt;BR /&gt;matrix C&lt;BR /&gt;RowPtr :1 4 7 &lt;BR /&gt;ColId :1 2 3 1 2 3 &lt;BR /&gt;9.00, 12.00, 15.00, &lt;BR /&gt;19.00, 26.00, 33.00, &lt;BR /&gt;&lt;BR /&gt;MKL 12&lt;BR /&gt;matric C&lt;BR /&gt;RowPtr :1 3 5 &lt;BR /&gt;ColId :1 2 1 2 &lt;BR /&gt;57.00, 12.00, 0.00, &lt;BR /&gt;19.00, 26.00, 0.00, &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Oct 2011 00:00:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805716#M3402</guid>
      <dc:creator>philvdm</dc:creator>
      <dc:date>2011-10-27T00:00:20Z</dc:date>
    </item>
    <item>
      <title>csrmultcsr  confusing calling API, not matching documentation</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805717#M3403</link>
      <description>Hi Philvdm,&lt;BR /&gt;&lt;BR /&gt;The discriptionof m, n, kis not aligned with other routines (we will fix this),but it is correctifreadit asCmxk=Amxn* Bnxk.&lt;BR /&gt;mkl_dcsrmultcsr(&amp;amp;trans, &amp;amp;request, &amp;amp;sort, &amp;amp;m, &amp;amp;n, &amp;amp;k, a, ja, ia, b, jb, ib, c, jc, ic, &amp;amp;nzmax, &amp;amp;info);&lt;BR /&gt;m INTEGER. Number of rows of the matrix A.&lt;BR /&gt;n INTEGER. Number of columns of the matrix A.&lt;BR /&gt;k INTEGER. Number of columns of the matrix B&lt;BR /&gt;&lt;BR /&gt;So for your case, you may try m=2, n=2, k=3. &lt;BR /&gt;for example, &lt;PRE&gt;[bash]!*******************************************************************************
*   Copyright(C) 2004-2011 Intel Corporation. All Rights Reserved.
*   
*   The source code, information  and  material ("Material") contained herein is
*   owned  by Intel Corporation or its suppliers or licensors, and title to such
*   Material remains  with Intel Corporation  or its suppliers or licensors. The
*   Material  contains proprietary information  of  Intel or  its  suppliers and
*   licensors. The  Material is protected by worldwide copyright laws and treaty
*   provisions. No  part  of  the  Material  may  be  used,  copied, reproduced,
*   modified, published, uploaded, posted, transmitted, distributed or disclosed
*   in any way  without Intel's  prior  express written  permission. No  license
*   under  any patent, copyright  or  other intellectual property rights  in the
*   Material  is  granted  to  or  conferred  upon  you,  either  expressly,  by
*   implication, inducement,  estoppel or  otherwise.  Any  license  under  such
*   intellectual  property  rights must  be express  and  approved  by  Intel in
*   writing.
*   
*   *Third Party trademarks are the property of their respective owners.
*   
*   Unless otherwise  agreed  by Intel  in writing, you may not remove  or alter
*   this  notice or  any other notice embedded  in Materials by Intel or Intel's
*   suppliers or licensors in any way.
*
********************************************************************************
*   Content : MKL Sparse BLAS Fortran example
*
********************************************************************************
C----------------------------------------------------------------------
C Example program to show the use of the MKL Sparse BLAS routines
C for multiplication of two compressed sparse row format matrices
C---------------------------------------------------------------------
      PROGRAM multiplication_test
      IMPLICIT NONE
C..  Description of all variables
      CHARACTER trans
      INTEGER m,n,k, sort, job, ierr, nzmax
      INTEGER ia(9), ib(9)
      INTEGER ja(18), jb(18)
      REAL*8 a(18),b(18), cden(8, 8), answer(8, 8) 
      REAL*8 zero
      REAL*8 ddum
      REAL*8 tolerance, normA, normres
      INTEGER ic, jc
      REAL*8 c
      POINTER (IC_PTR, IC(1)), (JC_PTR, JC(1)), (C_PTR, C(1))
      INTEGER i, j ,js, idum, nnz, sizeint 
      REAL*8  DNRM2
c#ifdef _IA32
      INTEGER*4   MKL_MALLOC
      INTEGER*4 alloc_size
c#else
C      INTEGER*8 MKL_MALLOC
C      INTEGER*8 alloc_size
c#endif  
c ..  
c .. Fill all arrays containing matrix data.
c ..
      DATA m/2/, n /2/, k/3/,sort/0/, sizeint/8/ 
      DATA zero/0.D0/
      DATA ia /1,3,5/
      DATA ja
     1 /1, 2, 
     2  1, 2/

    
      DATA a
     1 /1.d0,  2.d0,  
     2   3.d0, 4.d0/
    
      
      DATA ib /1,4,7/
      DATA jb
     1 /1,  2,  3,
     2  1,  2,  3/
    
     
      DATA b
     1 /1.d0,      2.d0,     3.d0,
     2    4.d0 ,   5.d0,     6.d0/
    
     


C.. This test computes A*B 
C..
      trans='N'
           
c ..
      alloc_size = sizeint*(n+1)
      ic_ptr=mkl_malloc(alloc_size, 128)  
      if(ic_ptr.eq.0) then
         write(*,*) 'Cannot allocate pointer array of the length ',n+1
         stop 1
      endif
      nzmax=n*n
      alloc_size =sizeint*nzmax
      jc_ptr=mkl_malloc(alloc_size, 128)  
      if(jc_ptr.eq.0) then
         write(*,*) 'Cannot allocate column array of the length ',nnz
         stop 1
      endif
      alloc_size =8*nzmax
      c_ptr=mkl_malloc(alloc_size, 128)  
      if(c_ptr.eq.0) then
         write(*,*) 'Cannot allocate value array of the length ', nnz
         stop 1
      endif
      job=0
      call mkl_dcsrmultcsr(trans, job, sort, m, n, k, a,ja,ia,
     *        b, jb, ib, c, jc, ic, nzmax, ierr)
c  
      if(ierr.ne.0)then 
         print  *,' FIRST TEST FAILED  '
         stop 1
      endif
      

      write(*,*) 'ic RowPtr'
      write(*,*) (ic(i),i=1,m+1)
      write(*,*) 'jc colld'
      write(*,*) (jc(i),i=1,ic(m+1)-1)
      write(*,*) 'c array=A*B'
      write(*,*) (c(i),i=1,ic(m+1)-1)
      
      
      end[/bash]&lt;/PRE&gt;&lt;BR /&gt;it will give you expected result.&lt;BR /&gt;ic RowPtr&lt;BR /&gt; 1 4 7&lt;BR /&gt;jc colld&lt;BR /&gt; 1 2 3 1 2 3&lt;BR /&gt;c array=A*B&lt;BR /&gt; 9.00000000000000 12.0000000000000 15.0000000000000&lt;BR /&gt; 19.0000000000000 26.0000000000000 33.0000000000000&lt;BR /&gt;Press any key to continue . . .&lt;BR /&gt;Regards,&lt;BR /&gt;Ying</description>
      <pubDate>Mon, 31 Oct 2011 01:27:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/csrmultcsr-confusing-calling-API-not-matching-documentation/m-p/805717#M3403</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2011-10-31T01:27:00Z</dc:date>
    </item>
  </channel>
</rss>

