<?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 From what you have posted I in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Strange-sparse-matrix-checker-Error-in-MKL-with-Matlab-MEX-file/m-p/1038648#M20584</link>
    <description>&lt;P&gt;From what you have posted I cannot gather what the mex-function arguments are. In particular, are you defining the sparse matrix in Matlab and passing the matrix (and other arguments) to the mex-function? If so, where do you convert from the COO representation used in Matlab to the CSR representation used in MKL/Pardiso?&lt;/P&gt;

&lt;P&gt;Can we see the source code for the mex-function? Which version of Matlab do you use?&lt;/P&gt;</description>
    <pubDate>Fri, 30 Oct 2015 02:40:00 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2015-10-30T02:40:00Z</dc:date>
    <item>
      <title>Strange sparse_matrix_checker() Error in MKL with Matlab MEX file</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Strange-sparse-matrix-checker-Error-in-MKL-with-Matlab-MEX-file/m-p/1038646#M20582</link>
      <description>&lt;P&gt;I am performing a simple test of a sparse matrix stores in CRS3 format with sparse_matrix_checker(). When I perform this test in the matrix_check.c MKL example code, it passes as expected. Also, I compiled the examples with GCC.&lt;/P&gt;

&lt;P&gt;However, when I perform an identical check in a Matlab C++ MEX function (also compiled with GCC), I get a strange error that doesn't make sense. The matrix is identical to the one given in the MKL documentation at &lt;A href="https://software.intel.com/en-us/node/471374"&gt;https://software.intel.com/en-us/node/471374&lt;/A&gt;. I am using zero-based indexing. Therefore, my row, column and value arrays are:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;/* Matrix data. */
    MKL_INT n = 5;
    MKL_INT ia[6] = {0,3,5,8,11,13};
    MKL_INT ja[13] =
      {0,1,3,0,1,2,3,4,0,2,3,1,4};
    double a[13] =
      {1,-1,-3,-2,5,4,6,4,-4,2,7,8,-5};&lt;/PRE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="BA54DCA8-3253-4EEA-8E8F-CA40CA13C022-imageId=6E57861E-B280-4A7B-AACB-06FC74ECFC79.gif"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/10251i4FB5C80B7EDAB575/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="BA54DCA8-3253-4EEA-8E8F-CA40CA13C022-imageId=6E57861E-B280-4A7B-AACB-06FC74ECFC79.gif" alt="BA54DCA8-3253-4EEA-8E8F-CA40CA13C022-imageId=6E57861E-B280-4A7B-AACB-06FC74ECFC79.gif" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;The parameters of my matrix check are:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;    pt.n = n;
    pt.csr_ia = ia;
    pt.csr_ja = ja;
    pt.indexing         = MKL_ZERO_BASED;
    pt.matrix_structure = MKL_GENERAL_STRUCTURE;
    pt.print_style      = MKL_C_STYLE; 
    pt.message_level    = MKL_PRINT;&lt;/PRE&gt;

&lt;P&gt;Again, when I run this check in matrix_check.c compiled from the examples, it passes. But when I compile this in a Matlab MEX, I get the error:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Matrix check result code: 21 (&lt;/STRONG&gt;MKL_SPARSE_CHECKER_NON_MONOTONIC&lt;STRONG&gt;)&lt;BR /&gt;
	Matrix check details: (1, 0, 0)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;However, this error doesn't make sense because ia[1] and ia[2] are not zero. Instead, they are 3 and 5.&lt;/STRONG&gt; Thus, it seems there is some memory read error by the MKL library.&lt;/P&gt;

&lt;P&gt;Note, I am compiling the MEX file with the following compiler options using &lt;STRONG&gt;G++ 4.9.2&lt;/STRONG&gt;:&lt;/P&gt;

&lt;P&gt;LDFLAGS=-m64 -I/opt/intel/compilers_and_libraries_2016.0.109/linux/mkl/include -L/opt/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_ilp64 -lmkl_gnu_thread myTest.cpp&lt;/P&gt;

&lt;P&gt;Also, I verified that the matrix is in fact stored correctly by reading it out in the Matlab MEX file:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;0: 	val: 1	cols: 0	rows: 0
1: 	val: -1	cols: 1	rows: 3
2: 	val: -3	cols: 3	rows: 5
3: 	val: -2	cols: 0	rows: 8
4: 	val: 5	cols: 1	rows: 11
&lt;STRONG&gt;5:			rows: 13&lt;/STRONG&gt;
5: 	val: 4	cols: 2
6: 	val: 6	cols: 3
7: 	val: 4	cols: 4
8: 	val: -4	cols: 0
9: 	val: 2	cols: 2
10: 	val: 7	cols: 3
11: 	val: 8	cols: 1
12: 	val: -5	cols: 4&lt;/PRE&gt;

&lt;P&gt;It seems to me that there is some issue caused by the way I am compiling this test that causes the MKL library to access memory differently than how it is being allocated. &lt;STRONG&gt;Does this make sense? Any thoughts or ideas for me to check?&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 01:47:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Strange-sparse-matrix-checker-Error-in-MKL-with-Matlab-MEX-file/m-p/1038646#M20582</guid>
      <dc:creator>Jonathan_C_2</dc:creator>
      <dc:date>2015-10-29T01:47:46Z</dc:date>
    </item>
    <item>
      <title>Hi Jonathen,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Strange-sparse-matrix-checker-Error-in-MKL-with-Matlab-MEX-file/m-p/1038647#M20583</link>
      <description>&lt;P&gt;Hi Jonathen,&lt;/P&gt;

&lt;P&gt;I haven't test.&amp;nbsp; But a tiny issue about mkl_intel_lp64&amp;nbsp;and mkl_intel_ilp64.&amp;nbsp; Do you know the int&amp;nbsp; type in&amp;nbsp;mex are 64bit or&amp;nbsp;32bit?&lt;/P&gt;

&lt;P&gt;Anyway,&amp;nbsp;&amp;nbsp;&amp;nbsp;you may try &amp;nbsp;-L/opt/intel/mkl/lib/intel64 -lmkl_core -lmkl_intel_lp64 and see if it works?&lt;/P&gt;

&lt;P&gt;or add -DMKL_ILP64 with mkl_intel_ilp64 in compile command line&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 01:29:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Strange-sparse-matrix-checker-Error-in-MKL-with-Matlab-MEX-file/m-p/1038647#M20583</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2015-10-30T01:29:00Z</dc:date>
    </item>
    <item>
      <title>From what you have posted I</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Strange-sparse-matrix-checker-Error-in-MKL-with-Matlab-MEX-file/m-p/1038648#M20584</link>
      <description>&lt;P&gt;From what you have posted I cannot gather what the mex-function arguments are. In particular, are you defining the sparse matrix in Matlab and passing the matrix (and other arguments) to the mex-function? If so, where do you convert from the COO representation used in Matlab to the CSR representation used in MKL/Pardiso?&lt;/P&gt;

&lt;P&gt;Can we see the source code for the mex-function? Which version of Matlab do you use?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 02:40:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Strange-sparse-matrix-checker-Error-in-MKL-with-Matlab-MEX-file/m-p/1038648#M20584</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2015-10-30T02:40:00Z</dc:date>
    </item>
  </channel>
</rss>

