<?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 How to use Intel® Math Kernel Library in MPI program in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-Intel-Math-Kernel-Library-in-MPI-program/m-p/954047#M15381</link>
    <description>&lt;P&gt;Dear all&lt;/P&gt;
&lt;P&gt;I am trying to compile the code MGS on intel(R)64 computer with intel (R) Composer XE 2013 ,Intel® Math Kernel Library 11.0.1.119 and MPICH2,.The code uses BLAS and LAPACK libraries.&lt;/P&gt;
&lt;P&gt;However, the sequential version of the compiled code works but the parallel one failed.&lt;/P&gt;
&lt;P&gt;Finally,I found the MKL functions may not work in parallel version.&lt;/P&gt;
&lt;P&gt;So my questions &amp;nbsp;are:&lt;/P&gt;
&lt;P&gt;(1)Can I use lapack and blacs MKL with the MPICH2 ?&lt;/P&gt;
&lt;P&gt;(2)which libraries is needed for my compilation ?&lt;/P&gt;
&lt;P&gt;The following is part of my code&lt;/P&gt;
&lt;P&gt;#include&amp;lt;mkl.h&amp;gt;&lt;BR /&gt;#include&amp;lt;cmath&amp;gt;&lt;BR /&gt;#include &amp;lt;complex&amp;gt;&lt;BR /&gt;#include&amp;lt;mkl_lapacke.h&amp;gt;&lt;BR /&gt;#include"iostream"&lt;BR /&gt;#include&amp;lt;fstream&amp;gt;&lt;BR /&gt;#include"mpi.h"&lt;BR /&gt;using namespace std;&lt;BR /&gt;MKL_Complex16 *data1(char *file,int &amp;amp;num)&lt;BR /&gt;{&lt;BR /&gt; ifstream fi;&lt;BR /&gt; int i,j,num_p;&lt;BR /&gt; fi.open(file);&lt;BR /&gt; fi&amp;gt;&amp;gt;num;&lt;BR /&gt; MKL_Complex16 *newZ;&lt;BR /&gt; newZ=new MKL_Complex16[num];&lt;BR /&gt; for(i=0;i&amp;lt;num;i++)&lt;BR /&gt; {&lt;BR /&gt; fi&amp;gt;&amp;gt;newZ&lt;I&gt;.real&amp;gt;&amp;gt;newZ&lt;I&gt;.imag;&lt;BR /&gt; }&lt;BR /&gt; return newZ;&lt;BR /&gt;}&lt;BR /&gt;int main(int argc,char *argv[])&lt;BR /&gt;{&lt;BR /&gt;int i1,i2,n,myid,numprocs,i,namelen;&lt;BR /&gt;char processor_name[MPI_MAX_PROCESSOR_NAME];&lt;BR /&gt;MPI_Init(&amp;amp;argc,&amp;amp;argv);&lt;BR /&gt;MPI_Comm_size(MPI_COMM_WORLD,&amp;amp;numprocs);&lt;BR /&gt;MPI_Comm_rank(MPI_COMM_WORLD,&amp;amp;myid);&lt;BR /&gt;MPI_Get_processor_name(processor_name,&amp;amp;namelen);&lt;BR /&gt;cout&amp;lt;&amp;lt;"process "&amp;lt;&amp;lt;myid&amp;lt;&amp;lt;" of "&amp;lt;&amp;lt;numprocs&amp;lt;&amp;lt;" "&amp;lt;&amp;lt;processor_name&amp;lt;&amp;lt;endl; &lt;BR /&gt;char data[10000]="data.txt";&lt;BR /&gt;//char processor_name[MPI_MAX_PROCESSOR_NAME];&lt;BR /&gt;char *dataname[100];&lt;BR /&gt;dataname[7]="data7.txt";&lt;BR /&gt;for(i2=myid;i2&amp;lt;8;i2+=numprocs)&lt;BR /&gt;{&lt;BR /&gt;lapack_int L,n,i,j,k,stat,LWORK,TLWORK,number2,N2,judge1,judge2;&lt;BR /&gt;long long N,N1,incX=1,incY=1;&lt;BR /&gt;int number1;&lt;BR /&gt;double dres1,dres2,dres3,dres4;&lt;BR /&gt;MKL_Complex16*A;&lt;BR /&gt;MKL_Complex16 B[10000];&lt;BR /&gt;MKL_Complex16 C[100],C1[100];&lt;BR /&gt;MKL_Complex16 D[100];&lt;BR /&gt;MKL_Complex16 E[100],E1[100],E2[100],E3[100],E4[10000];//E4 is used for verification&lt;BR /&gt;double E5[100];&lt;BR /&gt;double rkk;&lt;BR /&gt;MKL_Complex16 res1,res2,res3;&lt;BR /&gt;number2=10000;&lt;BR /&gt;A=new MKL_Complex16[number2];&lt;BR /&gt;data1(data,number1);&lt;BR /&gt;A=data1(data,number1);&lt;BR /&gt;for(i=0;i&amp;lt;100;i++)&lt;BR /&gt;{&lt;BR /&gt; for(j=0;j&amp;lt;100;j++)&lt;BR /&gt; {&lt;BR /&gt; B[i*100+j]=A[i*100+j];&lt;BR /&gt; }&lt;BR /&gt;}&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;for(i=0;i&amp;lt;100;i++)&lt;BR /&gt;{&lt;BR /&gt; for(j=0;j&amp;lt;100;j++)&lt;BR /&gt; {&lt;BR /&gt; C1&lt;J&gt;=B[j*100+i];&lt;BR /&gt; }&lt;BR /&gt; N1=100;&lt;BR /&gt; zdotc(&amp;amp;res1,&amp;amp;N1,C1,&amp;amp;incX,C1,&amp;amp;incY);&lt;BR /&gt; C&lt;I&gt;=res1;&lt;BR /&gt;}&lt;BR /&gt;cout&amp;lt;&amp;lt;"program over"&amp;lt;&amp;lt;endl;&lt;BR /&gt;char key;&lt;BR /&gt;cin&amp;gt;&amp;gt;key;&lt;BR /&gt;MPI_Finalize();&lt;BR /&gt;}&lt;/I&gt;&lt;/J&gt;&lt;/P&gt;
&lt;P&gt;I am a beginner in this area and i do need your help.&lt;/P&gt;
&lt;P&gt;Thank you very much for your help.&lt;/P&gt;
&lt;P&gt;Jack&lt;/P&gt;</description>
    <pubDate>Sat, 12 Oct 2013 12:38:34 GMT</pubDate>
    <dc:creator>jack_y_</dc:creator>
    <dc:date>2013-10-12T12:38:34Z</dc:date>
    <item>
      <title>How to use Intel® Math Kernel Library in MPI program</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-Intel-Math-Kernel-Library-in-MPI-program/m-p/954047#M15381</link>
      <description>&lt;P&gt;Dear all&lt;/P&gt;
&lt;P&gt;I am trying to compile the code MGS on intel(R)64 computer with intel (R) Composer XE 2013 ,Intel® Math Kernel Library 11.0.1.119 and MPICH2,.The code uses BLAS and LAPACK libraries.&lt;/P&gt;
&lt;P&gt;However, the sequential version of the compiled code works but the parallel one failed.&lt;/P&gt;
&lt;P&gt;Finally,I found the MKL functions may not work in parallel version.&lt;/P&gt;
&lt;P&gt;So my questions &amp;nbsp;are:&lt;/P&gt;
&lt;P&gt;(1)Can I use lapack and blacs MKL with the MPICH2 ?&lt;/P&gt;
&lt;P&gt;(2)which libraries is needed for my compilation ?&lt;/P&gt;
&lt;P&gt;The following is part of my code&lt;/P&gt;
&lt;P&gt;#include&amp;lt;mkl.h&amp;gt;&lt;BR /&gt;#include&amp;lt;cmath&amp;gt;&lt;BR /&gt;#include &amp;lt;complex&amp;gt;&lt;BR /&gt;#include&amp;lt;mkl_lapacke.h&amp;gt;&lt;BR /&gt;#include"iostream"&lt;BR /&gt;#include&amp;lt;fstream&amp;gt;&lt;BR /&gt;#include"mpi.h"&lt;BR /&gt;using namespace std;&lt;BR /&gt;MKL_Complex16 *data1(char *file,int &amp;amp;num)&lt;BR /&gt;{&lt;BR /&gt; ifstream fi;&lt;BR /&gt; int i,j,num_p;&lt;BR /&gt; fi.open(file);&lt;BR /&gt; fi&amp;gt;&amp;gt;num;&lt;BR /&gt; MKL_Complex16 *newZ;&lt;BR /&gt; newZ=new MKL_Complex16[num];&lt;BR /&gt; for(i=0;i&amp;lt;num;i++)&lt;BR /&gt; {&lt;BR /&gt; fi&amp;gt;&amp;gt;newZ&lt;I&gt;.real&amp;gt;&amp;gt;newZ&lt;I&gt;.imag;&lt;BR /&gt; }&lt;BR /&gt; return newZ;&lt;BR /&gt;}&lt;BR /&gt;int main(int argc,char *argv[])&lt;BR /&gt;{&lt;BR /&gt;int i1,i2,n,myid,numprocs,i,namelen;&lt;BR /&gt;char processor_name[MPI_MAX_PROCESSOR_NAME];&lt;BR /&gt;MPI_Init(&amp;amp;argc,&amp;amp;argv);&lt;BR /&gt;MPI_Comm_size(MPI_COMM_WORLD,&amp;amp;numprocs);&lt;BR /&gt;MPI_Comm_rank(MPI_COMM_WORLD,&amp;amp;myid);&lt;BR /&gt;MPI_Get_processor_name(processor_name,&amp;amp;namelen);&lt;BR /&gt;cout&amp;lt;&amp;lt;"process "&amp;lt;&amp;lt;myid&amp;lt;&amp;lt;" of "&amp;lt;&amp;lt;numprocs&amp;lt;&amp;lt;" "&amp;lt;&amp;lt;processor_name&amp;lt;&amp;lt;endl; &lt;BR /&gt;char data[10000]="data.txt";&lt;BR /&gt;//char processor_name[MPI_MAX_PROCESSOR_NAME];&lt;BR /&gt;char *dataname[100];&lt;BR /&gt;dataname[7]="data7.txt";&lt;BR /&gt;for(i2=myid;i2&amp;lt;8;i2+=numprocs)&lt;BR /&gt;{&lt;BR /&gt;lapack_int L,n,i,j,k,stat,LWORK,TLWORK,number2,N2,judge1,judge2;&lt;BR /&gt;long long N,N1,incX=1,incY=1;&lt;BR /&gt;int number1;&lt;BR /&gt;double dres1,dres2,dres3,dres4;&lt;BR /&gt;MKL_Complex16*A;&lt;BR /&gt;MKL_Complex16 B[10000];&lt;BR /&gt;MKL_Complex16 C[100],C1[100];&lt;BR /&gt;MKL_Complex16 D[100];&lt;BR /&gt;MKL_Complex16 E[100],E1[100],E2[100],E3[100],E4[10000];//E4 is used for verification&lt;BR /&gt;double E5[100];&lt;BR /&gt;double rkk;&lt;BR /&gt;MKL_Complex16 res1,res2,res3;&lt;BR /&gt;number2=10000;&lt;BR /&gt;A=new MKL_Complex16[number2];&lt;BR /&gt;data1(data,number1);&lt;BR /&gt;A=data1(data,number1);&lt;BR /&gt;for(i=0;i&amp;lt;100;i++)&lt;BR /&gt;{&lt;BR /&gt; for(j=0;j&amp;lt;100;j++)&lt;BR /&gt; {&lt;BR /&gt; B[i*100+j]=A[i*100+j];&lt;BR /&gt; }&lt;BR /&gt;}&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;for(i=0;i&amp;lt;100;i++)&lt;BR /&gt;{&lt;BR /&gt; for(j=0;j&amp;lt;100;j++)&lt;BR /&gt; {&lt;BR /&gt; C1&lt;J&gt;=B[j*100+i];&lt;BR /&gt; }&lt;BR /&gt; N1=100;&lt;BR /&gt; zdotc(&amp;amp;res1,&amp;amp;N1,C1,&amp;amp;incX,C1,&amp;amp;incY);&lt;BR /&gt; C&lt;I&gt;=res1;&lt;BR /&gt;}&lt;BR /&gt;cout&amp;lt;&amp;lt;"program over"&amp;lt;&amp;lt;endl;&lt;BR /&gt;char key;&lt;BR /&gt;cin&amp;gt;&amp;gt;key;&lt;BR /&gt;MPI_Finalize();&lt;BR /&gt;}&lt;/I&gt;&lt;/J&gt;&lt;/P&gt;
&lt;P&gt;I am a beginner in this area and i do need your help.&lt;/P&gt;
&lt;P&gt;Thank you very much for your help.&lt;/P&gt;
&lt;P&gt;Jack&lt;/P&gt;</description>
      <pubDate>Sat, 12 Oct 2013 12:38:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-Intel-Math-Kernel-Library-in-MPI-program/m-p/954047#M15381</guid>
      <dc:creator>jack_y_</dc:creator>
      <dc:date>2013-10-12T12:38:34Z</dc:date>
    </item>
    <item>
      <title>yes, sure MKL works with</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-Intel-Math-Kernel-Library-in-MPI-program/m-p/954048#M15382</link>
      <description>&lt;P&gt;yes, sure MKL works with MPICH2 too ( see the release notes &lt;A href="http://software.intel.com/en-us/articles/intel-mkl-111-system-requirements/"&gt;http://software.intel.com/en-us/articles/intel-mkl-111-system-requirements/&lt;/A&gt;&amp;nbsp;).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;there are mkl linker adviser which help you to find the list and order of libraries for linking your application with MKL&lt;/P&gt;
&lt;P&gt;&lt;A href="http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor"&gt;http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;also, you can find cluster's example ( example_cluster.zip &amp;nbsp;) which you will find into &amp;lt;mkl_install dir&amp;gt;\example directory&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2013 03:44:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-use-Intel-Math-Kernel-Library-in-MPI-program/m-p/954048#M15382</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2013-10-13T03:44:51Z</dc:date>
    </item>
  </channel>
</rss>

