Comment relier la bibliothèque Intel MKL, seule la fonction cblas_dgemm est utilisée

Je veux tester la multiplication de la masortingce Intel MKL , donc j’inclus et je viens d’utiliser la fonction cblas_dgemm, mais il dit toujours

  undefined reference to `cblas_dgemm' 

Je lie également le -lmkl_core -lmkl_blas95_lp64 -lmkl_lapack95_lp64 , mais j’ai -lmkl_core -lmkl_blas95_lp64 -lmkl_lapack95_lp64 nombreuses combinaisons entre les bibliothèques du $MKLROOT/lib/intel64/ , l’erreur existe toujours. Quelqu’un pourrait-il me donner des conseils, s’il vous plaît? Merci.

    Peut-être que c’est une bonne réponse, nous pouvons utiliser cblas_ :

    Dans le fichier de projet d’un créateur QT:

      unix { INCLUDEPATH += /opt/intel/mkl/include LIBS += -L/opt/intel/mkl/lib/intel64 \ -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core \ -L/opt/intel/lib/intel64 \ -liomp5 -lpthread -dl -lm } 

    Voici le main.cpp pour le test cblas_* dans MKL :

      #include  using namespace std; #include  #include  #include  #include  #include  #include  #include  #include  template void printArray(T *data, char *name, int len){ cout << name << "\n"; for(int i=0;i void printMasortingx(T *data, char *name, int m, int n){ cout << name << "\n"; for(int i=0;i(x, "x", len); printArray(y, "y", len); //sum(x) double x_sum=cblas_dasum(len,x,1); cout<< "sum(x): "<< x_sum <<"\n"; //y=a*x+y double alpha=1; cblas_daxpy(len,alpha,x,1,y,1); printArray(y,"y=a*x+y",len); //y=x cblas_dcopy(len,x,1,y,1); printArray(y,"y=x",len); //x*y'; double xy_dot=cblas_ddot(len,x,1,y,1); cout <<"x*y': "<(x,"x:",len); printArray(y,"y:",len); //LEVEL 2 BLAS //masortingx and vector manipulation int m=len; int n=len; double *A=new double[m*n]; for(int i=0;i(A,"A",m,n); //masortingx and vector multiplication double alpha_dgemv=1.0; double beta_dgemv=1.0; //y=alpha*A*x+beta*y, if A is a mxn band masortingx, then use cblas_dgbmv cblas_dgemv(CblasRowMajor,CblasNoTrans,m,n,alpha_dgemv,A,m,x,1,beta_dgemv,y,1); printArray(x,"x:",len); printArray(y,"y=alpha*A*x+beta*y",len); //y=alpha*A'*x+beta*y cblas_dgemv(CblasRowMajor,CblasTrans,m,n,alpha_dgemv,A,m,x,1,beta_dgemv,y,1); printArray(x,"x:",len); printArray(y,"y=alpha*A'*x+beta*y",len); //A=alpha*x*y'+A; double alpha_dger=1.0; cblas_dger(CblasRowMajor,m,n,alpha_dger,x,1,y,1,A,m); printArray(x,"x:",len); printArray(y,"y:",len); printMasortingx(A,"A=alpha1*x*y'+A",m,n); delete[] x;x=NULL; delete[] y;y=NULL; delete[] A;A=NULL; // m=10; n=5; int k=3; double *Amxk=new double[m*k]; double *Bkxn=new double[k*n]; double *Cmxn=new double[m*n]; for(int i=0;i(Amxk,"Amxk",m,k); printMasortingx(Bkxn,"Bkxn",k,n); printMasortingx(Cmxn,"Cmxn",m,n); double alpha_dgemm=1.0; double beta_dgemm=1.0; cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, alpha_dgemm, Amxk, k, Bkxn, n, beta_dgemm, Cmxn, n); printMasortingx(Cmxn,"Cmxn",m,n); delete[] Amxk; delete[] Bkxn; delete[] Cmxn; //general symmesortingc masortingx eigenvalue decomposition /* Locals */ const MKL_INT N=5; const MKL_INT LDA=5; MKL_INT lda = LDA, info; n=N; /* Local arrays */ double w[N]; double a[LDA*N] = { 6.39, 0.13, -8.23, 5.71, -3.18, 0.00, 8.37, -4.46, -6.10, 7.21, 0.00, 0.00, -9.58, -9.25, -7.42, 0.00, 0.00, 0.00, 3.72, 8.54, 0.00, 0.00, 0.00, 0.00, 2.51 }; /* Executable statements */ printf( "LAPACKE_dsyevd (row-major, high-level) Example Program Results\n" ); /* Solve eigenproblem */ info = LAPACKE_dsyevd( LAPACK_ROW_MAJOR, 'V', 'U', n, a, lda, w ); /* Check for convergence */ if( info > 0 ) { printf( "The algorithm failed to compute eigenvalues.\n" ); exit( 1 ); } printArray(w,"w:",N); printMasortingx(a,"a:",N,N); int N1=10; int d=3; double *A1=new double[N1*d]; for(int j=0;j(A1,"A:",d,N1); double *A_mean=new double[1*d]; for(int i=0;i(A_mean,"A_mean",d); delete[] A1;A1=NULL; delete[] A_mean;A_mean=NULL; return 0; } 

    Ensuite, dans terminal, tapez le code suivant pour charger les parameters d’environnement:

      source /opt/intel/bin/comstackrvars.sh intel64 

    La solution Line Line Advisor de Intel® Math Kernel Library est exactement ce qu’il vous faut. Il peut générer les options de compilation / lien appropriées pour vous.

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