How to use Intel® Math Kernel Library in MPI program

How to use Intel® Math Kernel Library in MPI program

jack y.的头像

Dear all

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.

However, the sequential version of the compiled code works but the parallel one failed.

Finally,I found the MKL functions may not work in parallel version.

So my questions  are:

(1)Can I use lapack and blacs MKL with the MPICH2 ?

(2)which libraries is needed for my compilation ?

The following is part of my code

#include<mkl.h>
#include<cmath>
#include <complex>
#include<mkl_lapacke.h>
#include"iostream"
#include<fstream>
#include"mpi.h"
using namespace std;
MKL_Complex16 *data1(char *file,int &num)
{
ifstream fi;
int i,j,num_p;
fi.open(file);
fi>>num;
MKL_Complex16 *newZ;
newZ=new MKL_Complex16[num];
for(i=0;i<num;i++)
{
fi>>newZ[i].real>>newZ[i].imag;
}
return newZ;
}
int main(int argc,char *argv[])
{
int i1,i2,n,myid,numprocs,i,namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
MPI_Get_processor_name(processor_name,&namelen);
cout<<"process "<<myid<<" of "<<numprocs<<" "<<processor_name<<endl;
char data[10000]="data.txt";
//char processor_name[MPI_MAX_PROCESSOR_NAME];
char *dataname[100];
dataname[7]="data7.txt";
for(i2=myid;i2<8;i2+=numprocs)
{
lapack_int L,n,i,j,k,stat,LWORK,TLWORK,number2,N2,judge1,judge2;
long long N,N1,incX=1,incY=1;
int number1;
double dres1,dres2,dres3,dres4;
MKL_Complex16*A;
MKL_Complex16 B[10000];
MKL_Complex16 C[100],C1[100];
MKL_Complex16 D[100];
MKL_Complex16 E[100],E1[100],E2[100],E3[100],E4[10000];//E4 is used for verification
double E5[100];
double rkk;
MKL_Complex16 res1,res2,res3;
number2=10000;
A=new MKL_Complex16[number2];
data1(data,number1);
A=data1(data,number1);
for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
B[i*100+j]=A[i*100+j];
}
}

for(i=0;i<100;i++)
{
for(j=0;j<100;j++)
{
C1[j]=B[j*100+i];
}
N1=100;
zdotc(&res1,&N1,C1,&incX,C1,&incY);
C[i]=res1;
}
cout<<"program over"<<endl;
char key;
cin>>key;
MPI_Finalize();
}

I am a beginner in this area and i do need your help.

Thank you very much for your help.

Jack

2 帖子 / 0 new
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Gennady Fedorov (Intel)的头像

yes, sure MKL works with MPICH2 too ( see the release notes http://software.intel.com/en-us/articles/intel-mkl-111-system-requirements/ ). 

there are mkl linker adviser which help you to find the list and order of libraries for linking your application with MKL

http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

also, you can find cluster's example ( example_cluster.zip  ) which you will find into <mkl_install dir>\example directory

登陆并发表评论。