《数学库数值计算库 Intel Mathematics Kernel Library (MKL) Quickstart.ppt》由会员分享,可在线阅读,更多相关《数学库数值计算库 Intel Mathematics Kernel Library (MKL) Quickstart.ppt(24页珍藏版)》请在三一办公上搜索。
1、1,Intel Mathematics Kernel Library(MKL)Quickstart,COLA Lab,Department of Mathematics,Natl Taiwan University2010/05/11,2,Intel MKL Quickstart,Credits,Credits,Wei-Ren Chang 張為仁(slides and codes,2009/03/10)Lien-Chi Lai 賴鍊奇(slides,2010/05/11),3,Intel MKL Quickstart,A Brief Introduction,4,Intel MKL Quick
2、start,Intel MKL:Intel Math Kernel Library,Introduction,Availability:Windows,LinuxFunctionalityDense and Sparse Linear Algebra:BLAS,LAPACKSparse Solvers:Direct and Iterative SolversFast Fourier TransformsCluster Support:ScaLAPACK,Cluster FFTFeatures and BenefitsAutomatic parallelizationStandard APIs
3、in C and Fortran,5,Intel MKL Quickstart,User Guide,MKL User GuideInstallationDevelopment Environment ConfigurationPerformance and Memory ManagementLanguage-specific Usage OptionsDefault documents directory/opt/intel/mkl/10.2.1.017/doc/userguide.pdf,User Guide,6,Intel MKL Quickstart,Reference Manual,
4、MKL Reference ManualThe routines and functions descriptionAPIs in C and FortranInterfaces and calling syntaxDefault documents directory/opt/intel/mkl/10.2.1.017/doc/mklman.pdf,Reference Manual,7,Intel MKL Quickstart,Some Examples,8,Intel MKL Quickstart,Examples,Brief examples toCompute Inner product
5、(sequential)Compute the LU factorization of a matrixSolve linear systemSolve eigen systemCompute Inner product(parallel),Examples,9,Intel MKL Quickstart,Directories containing the source codes,mkl_blas_f95(mkl_blas_c)mkl_lapack95_f95(mkl_lapack95_c)mkl_linearsym_f95(mkl_linearsym_c)mkl_eigensym_f95(
6、mkl_eigensym_c)mkl_blas_f95_p(mkl_blas_c_p),File names,10,Intel MKL Quickstart,Inner product(sequential),Examples,do ii=1,n vec_a(ii)=1.25*ii vec_b(ii)=0.75*iiend dodot_result=ddot(n,vec_a,inca,vec_b,incb),Inner product,11,Intel MKL Quickstart,Input parameters,Inner product,dot_result=ddot(n,vec_a,i
7、nca,vec_b,incb)n:The length of two vectors.inca:Specifies the increment for the elements of vec_aincb:Specifies the increment for the elements of vec_bvec_a:The fitsr vectorvec_b:The second vector,Input parameters,12,Intel MKL Quickstart,Output parameters,Inner product,dot_result:The final result,Ou
8、tput parameters,13,Intel MKL Quickstart,Inner product(parallel),Examples,Makefile clipsFC=mpif90MKL_INCLUDE=/opt/intel/mkl/10.0.3.020/includeMKL_PATH=/opt/intel/mkl/10.0.3.020/lib/em64tEXE=blas_f95.exeblas_f:$(FC)-o$(EXE)blas_f.f90-I$(MKL_INCLUDE)-L$(MKL_PATH)-lmkl_intel_lp64-lmkl_intel_thread-lmkl_
9、core-lguide-lpthread,Inner product(parallel),14,Intel MKL Quickstart,LU factorization,Examples,Define the matrixa(1,1)=1a(1,2)=3a(2,1)=2a(2,2)=1Compute LU factorizationcall dgetrf(m,n,a,lda,ipiv,info),LU factorization,15,Intel MKL Quickstart,Input parameters,LU factorization,call dgetrf(m,n,a,lda,ip
10、iv,info)a:The matrix.m:The number of rows in the matrix an:The number of columns in the matrix alda:The fitsr dimension of a,Input parameters,16,Intel MKL Quickstart,Output parameters,LU factorization,call dgetrf(m,n,a,lda,ipiv,info)a:overwritten by L and U.The unit diagonal elements of L are skippe
11、dipiv:An array,dimension at least max(1,min(m,n).The pivot indices:row i is interchanged with row ipiv(i)info:info=0,the execution is successfulinfo=-i,the i-th parameter had an illegal valueinfo=i,uii is 0.The factorization has been completed,but U is exactly singular,Output parameters,17,Intel MKL
12、 Quickstart,Linear System(Fortran),Examples,Define the matrixa(1,1)=1a(1,2)=3a(2,1)=2a(2,2)=1Define the right-hand siderhs(1)=1.0rhs(2)=1.0Solve the linear systemcall dgesv(n,nrhs,a,lda,ipiv,ths,ldb,info),Linear System,18,Intel MKL Quickstart,Input parameters,Linear System,call dgesv(n,nrhs,a,lda,ip
13、iv,ths,ldb,info)n:The number of linear equations,that is,the order of the matrix a rhs:Right-hand sidelda:The leading dimension of matrix anrhs:The number of right-hand sides,Input parameters,19,Intel MKL Quickstart,Output parameters,Linear System,call dgesv(n,nrhs,a,lda,ipiv,ths,ldb,info)ipiv:An ar
14、ray,dimension at least max(1,min(m,n).The pivot indices:row i was interchanged with row ipiv(i)rhs:Overwritten by the solution matrix ainfo:info=0,the execution is successfulinfo=-i,the i-th parameter had an illegal valueinfo=i,U(i,i)is 0.The factorization has been completed,but U is exactly singula
15、r,so the solution could not be computed,Output parameters,20,Intel MKL Quickstart,Eigensystem(symmetric),Examples,Define the matrixdsyeva(1,1)=1.0a(1,2)=2.0a(2,1)=2.0a(2,2)=3.0Call MKL functioncall dsyev(jobz,uplo,dim,a,lda,eigval,work,lwork,info),Eigensystem,21,Intel MKL Quickstart,Input parameters
16、,Eigensystem,call dsyev(jobz,uplo,dim,a,lda,eigval,work,lwork,info)jobz:If jobz=N,then only eigenvalues are computedjobz:If jobz=V,then eigenvalues are eigenvectors are computeduplo:If uplo=U,a stores the upper triangular part of auplo:If uplo=L,a stores the lower triangular part of alda:The first d
17、imension of awork:a workspace array,its dimension max(1,lwork)lwork:The dimension of the array work,Input parameters,22,Intel MKL Quickstart,Output parameters,call dsyev(jobz,uplo,dim,a,lda,eigval,work,lwork,info)wigval:contains the eigenvalues of the matrix a in ascending orderinfo:info=0,the execu
18、tion is successfulinfo=-i,the i-th parameter had an illegal valueinfo=i,then the algorithm failed to converge;I indicates the number of elements of an intermediate tridiagonal form which did not converge to zero,Output parameters,Eigensystem,23,Intel MKL Quickstart,References,24,Intel MKL Quickstart,Reference,Intel Math Kernel Library Reference Manual(mklman.pdf)Intel Math Kernel Library for the Linux OS Users Guide(userguide.pdf)http:/,Reference,