<?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 Hi, thank you for your in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120009#M24910</link>
    <description>&lt;P&gt;Hi, thank you for your informative advice!&lt;/P&gt;

&lt;P&gt;You are right. The problem is indeed caused by the ILP64 and LP64. I was hoping to use the ILP64 interface to compile the code, but it seems that the UMFpack cannot work with ILP64. For the switches "-DMKL_ILP64 -openmp -mkl=parallel -lpthread -lm", I got these from the linking advisor as what you just mentioned. But at that time I chose the Intel product as "Intel Composer XE 2013" instead of "Intel MKL 11.0".&lt;/P&gt;

&lt;P&gt;So another question is what should I choose for "Intel product" in the linking advisor if I want to link to MKL using icc and gcc in Linux? In other word, when should I use the full set of switches "-I${MKLROOT}/include -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread" instead of simply "-mkl=parallel"?&lt;/P&gt;

&lt;P&gt;The full set of switches will make mkl_cspblas_dcsrgemv() gives correct results while the shorter switches gives wrong answer. (e.g. in the simple testing of test1.c). What is the reason behind the choice of those linking switches?&lt;/P&gt;

&lt;P&gt;I will try to compile the code with LP64 and see if there is any problem.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2016 16:23:39 GMT</pubDate>
    <dc:creator>Hanqing_W_</dc:creator>
    <dc:date>2016-03-22T16:23:39Z</dc:date>
    <item>
      <title>mkl_cspblas_dcsrgemv gives wrong results</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120007#M24908</link>
      <description>&lt;P&gt;I was trying to compute the sparse matrix-vector multiplication using mkl_cspblas_dcsrgemv() in the MKL.&lt;/P&gt;

&lt;P&gt;The c compiler comes from composer_xe_2013.0.079 in the parallelstudio_2013 version with all the environment variables set up. (by sourcing the iccvars.sh)&lt;/P&gt;

&lt;P&gt;The strange thing is that if I compile the code with the switch:&lt;/P&gt;

&lt;P&gt;icc test1.c -g -DMKL_ILP64 -openmp -mkl=parallel -lpthread -lm&lt;/P&gt;

&lt;P&gt;mkl_cspblas_dcsrgemv() gives the wrong answer.&lt;/P&gt;

&lt;P&gt;However, if I compile the code with:&lt;/P&gt;

&lt;P&gt;icc test1.c -g -DMKL_ILP64 -openmp -I${MKLROOT}/include -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lpthread -lm&lt;/P&gt;

&lt;P&gt;the answer is correct.&lt;/P&gt;

&lt;P&gt;The source file of test1.c is:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;// test1.c
#include &amp;lt;mkl.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

int main(int argc, char **argv)
{
MKL_INT n = 5 ;
MKL_INT Ap [ ] = {0, 2, 5, 9, 10, 12} ;
MKL_INT Ai [ ] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, 4} ;
double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ;
double b [ ] = {8., 45., -3., 3., 19.} ;
double x [5] ;

printf("sizeof long: %lu\n",sizeof(long));
printf("sizeof MKL_INT: %lu\n",sizeof(MKL_INT));

mkl_cspblas_dcsrgemv("T",&amp;amp;n,Ax,Ap,Ai,b,x);

printf("%f  %f  %f  %f  %f\n",x[0],x[1],x[2],x[3],x[4]);

return 0;
}&lt;/PRE&gt;

&lt;P&gt;More strange thing is that if I compile the whole program with the latter set of switches, the umfpack does not work. To test it, the code test2.c gives an example from the manual of umfpack.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;// test2.c
#include &amp;lt;stdio.h&amp;gt;
#include "umfpack.h"

int n = 5 ;
int Ap [ ] = {0, 2, 5, 9, 10, 12} ;
int Ai [ ] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, 4} ;
double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ;
double b [ ] = {8., 45., -3., 3., 19.} ;
double x [5] ;

int main (void)
{
double *null = (double *) NULL ;
int i ;
void *Symbolic, *Numeric ;
(void) umfpack_di_symbolic (n, n, Ap, Ai, Ax, &amp;amp;Symbolic, null, null) ;
(void) umfpack_di_numeric (Ap, Ai, Ax, Symbolic, &amp;amp;Numeric, null, null) ;
umfpack_di_free_symbolic (&amp;amp;Symbolic) ;
(void) umfpack_di_solve (UMFPACK_A, Ap, Ai, Ax, x, b, Numeric, null, null) ;
umfpack_di_free_numeric (&amp;amp;Numeric) ;
for (i = 0 ; i &amp;lt; n ; i++) printf ("x [%d] = %g\n", i, x &lt;I&gt;) ;
return (0) ;
}&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;If I compile test2.c using (same as the latter set of switches above that can make mkl_cspblas_dcsrgemv work):&lt;/P&gt;

&lt;P&gt;icc test14.c -I/mnt/home/software/SuiteSparse/include -I${MKLROOT}/include -Wall -g -openmp -DMKL_ILP64 -L./lib -L/mnt/home/software/SuiteSparse/lib -L${MKLROOT}/lib/intel64 -Wl,-Bstatic -lumfpack -lamd -lsuitesparseconfig -lcholmod -lcolamd -Wl,-Bdynamic -lm -lrt&amp;nbsp; -ldl -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread&lt;/P&gt;

&lt;P&gt;The umfpack will get SIGSEGV when it calls mkl_blas_xdgemv().&lt;/P&gt;

&lt;P&gt;However, with the set of MKL switch that makes mkl_cspblas_dcsrgemv() give wrong answer:&lt;/P&gt;

&lt;P&gt;icc test14.c -I/mnt/home/software/SuiteSparse/include -L/mnt/home/software/SuiteSparse/lib -Wl,-Bstatic -lumfpack -lamd -lsuitesparseconfig -lcholmod -lcolamd -Wl,-Bdynamic -lm -lrt -lpthread -ldl&lt;/P&gt;

&lt;P&gt;The umfpack works well.&lt;/P&gt;

&lt;P&gt;Same problem also happens on Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 12.1.0.233 Build 20110811.&lt;/P&gt;

&lt;P&gt;Since my program needs to have both umfpack and sparse matrix-vector multiplication work together, I am stuck at this point. Could you help locate where the problem is and how to solve it? Is it a bug of umfpack or MKL?&lt;/P&gt;

&lt;P&gt;Thank you very much for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Mar 2016 22:01:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120007#M24908</guid>
      <dc:creator>Hanqing_W_</dc:creator>
      <dc:date>2016-03-21T22:01:24Z</dc:date>
    </item>
    <item>
      <title>Hi, </title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120008#M24909</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The problem seems be unmatched between &amp;nbsp;the ILP64 interface (MKL_INT is 64bit integer, Long and pointer are 64bit) and LP64 library. Could you please tell us which model you perfer?&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Regarding the test1.c&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;icc test1.c -g -DMKL_ILP64 -openmp -mkl=parallel -lpthread -lm. &amp;nbsp; &amp;nbsp;you have "-DMKL_ILP64", &amp;nbsp;so you hope that MKL_INT is 64bit integer, right?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;But -mkl=parallel &amp;nbsp;means &amp;nbsp;&lt;/SPAN&gt;-lmkl_intel_&lt;STRONG&gt;lp64&lt;/STRONG&gt; &amp;nbsp;-lmkl_intel_thread &lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;-lmkl_core&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;According to the MKL link advisor &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;&lt;A href="https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/" target="_blank"&gt;https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/&lt;/A&gt;, the correct one are&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px; line-height: 1.5;"&gt;cc test1.c -g -DMKL_ILP64 -openmp -I${MKLROOT}/include -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lpthread -lm&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;So the answer is correct.&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Regarding the&amp;nbsp;&lt;SPAN style="color: rgb(0, 130, 0); font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 13.008px; line-height: 14.3088px;"&gt;// test2.c.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;&lt;SPAN style="color: rgb(128, 128, 128); font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; font-size: 13.008px; font-weight: bold; line-height: 14.3088px;"&gt;You have int type in the code , which may pass 32bit integer to 64bit ILP model.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; line-height: 18px;"&gt;mkl_blas_xdgemv()&lt;/SPAN&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;As i guess, one of &amp;nbsp;solution may be just use lp64 model. &amp;nbsp;for example, &amp;nbsp; mkl_intel_lp64&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;icc test14.c -I/mnt/home/software/SuiteSparse/include -I${MKLROOT}/include -Wall -g -openmp &amp;nbsp;-L./lib -L/mnt/home/software/SuiteSparse/lib -L${MKLROOT}/lib/intel64 -Wl,-Bstatic -lumfpack -lamd -lsuitesparseconfig -lcholmod -lcolamd -Wl,-Bdynamic -lm -lrt&amp;nbsp; -ldl -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread.&amp;nbsp;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Would you like to try this and let us know the result?&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;BTW, the latest MKL release is MKL 11.3 update 2. &amp;nbsp;get from &amp;nbsp;&lt;U&gt;&lt;A href="http://software.intel.com/en-us/articles/intel-mkl/"&gt;http://software.intel.com/en-us/articles/intel-mkl/&lt;/A&gt;&lt;/U&gt;&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Best Regards,&lt;/P&gt;

&lt;P style="word-wrap: break-word; font-size: 12px;"&gt;Ying H.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 01:28:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120008#M24909</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2016-03-22T01:28:22Z</dc:date>
    </item>
    <item>
      <title>Hi, thank you for your</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120009#M24910</link>
      <description>&lt;P&gt;Hi, thank you for your informative advice!&lt;/P&gt;

&lt;P&gt;You are right. The problem is indeed caused by the ILP64 and LP64. I was hoping to use the ILP64 interface to compile the code, but it seems that the UMFpack cannot work with ILP64. For the switches "-DMKL_ILP64 -openmp -mkl=parallel -lpthread -lm", I got these from the linking advisor as what you just mentioned. But at that time I chose the Intel product as "Intel Composer XE 2013" instead of "Intel MKL 11.0".&lt;/P&gt;

&lt;P&gt;So another question is what should I choose for "Intel product" in the linking advisor if I want to link to MKL using icc and gcc in Linux? In other word, when should I use the full set of switches "-I${MKLROOT}/include -L${MKLROOT}/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread" instead of simply "-mkl=parallel"?&lt;/P&gt;

&lt;P&gt;The full set of switches will make mkl_cspblas_dcsrgemv() gives correct results while the shorter switches gives wrong answer. (e.g. in the simple testing of test1.c). What is the reason behind the choice of those linking switches?&lt;/P&gt;

&lt;P&gt;I will try to compile the code with LP64 and see if there is any problem.&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 16:23:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120009#M24910</guid>
      <dc:creator>Hanqing_W_</dc:creator>
      <dc:date>2016-03-22T16:23:39Z</dc:date>
    </item>
    <item>
      <title>gcc doesn't apply -mkl</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120010#M24911</link>
      <description>&lt;P&gt;gcc doesn't apply -mkl options, so you must specify -L and -l settings, even if you want a basic dynamic library option.&amp;nbsp; Also, for gcc, you should either choose mkl_gnu_thread in place of mkl_intel_thread (using gcc's own -lgomp), or add -liomp5, as the Link Advisor says.&amp;nbsp; libiomp5 supports OpenMP function calls from linux gcc as well as icc and libmkl_intel_thread.&lt;/P&gt;

&lt;P&gt;Link Advisor gives the command line for either icc or linux gcc, and, in the latter case, for either libgomp or libiomp5.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;You have also the possibility of using the TBB threading layer in case your application uses either Cilk(tm) Plus or TBB threads but not OpenMP.&amp;nbsp; Documentation about that option looks scanty.&lt;/P&gt;

&lt;P&gt;You probably noticed that the preferred OpenMP switch for current icc is -qopenmp, while for gcc it's -fopenmp. When such a switch is passed at link time, it's equivalent to -liomp5 or -lgomp respectively, followed by -lpthread.&lt;/P&gt;

&lt;P&gt;Likewise, -mkl=parallel is equivalent to the MKL options you quoted (with lp64), together with -qopenmp.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;You've probably figured out ilp64 vs. lp64 by now; all your code would need to use long int rather than int data types in the MKL function calls in order to use ilp64 and support arrays of size more than 2 billion.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2016 17:39:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120010#M24911</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2016-03-22T17:39:00Z</dc:date>
    </item>
    <item>
      <title>Thank you for your reply. I</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120011#M24912</link>
      <description>&lt;P&gt;Thank you for your reply. I tried to compile the code with LP64 interface and it works fine. From what I found in the Suitesparse 4.5.1, it can only work with LP64. So currently it is impossible to use ILP64 interface with UMFpack, which limits the MKL_INT to 32bit integer.&lt;/P&gt;

&lt;P&gt;Anyway I think the problem is solved at this moment. Thank all of you for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2016 00:15:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-cspblas-dcsrgemv-gives-wrong-results/m-p/1120011#M24912</guid>
      <dc:creator>Hanqing_W_</dc:creator>
      <dc:date>2016-03-23T00:15:19Z</dc:date>
    </item>
  </channel>
</rss>

