Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intel Math Kernel Library Wei-Ren Chang, Department of Mathematics, National Taiwan University 2009/03/10.

Similar presentations


Presentation on theme: "Intel Math Kernel Library Wei-Ren Chang, Department of Mathematics, National Taiwan University 2009/03/10."— Presentation transcript:

1 Intel Math Kernel Library Wei-Ren Chang, Department of Mathematics, National Taiwan University 2009/03/10

2 Introduction to MKL2 A brief introduction

3 Introduction Introduction to MKL3 MKL offers highly optimized, thread-safe math routines for science, engineering, and financial applications that require maximum performance.

4 Some information4

5 Intel MKL Reference Manual Some information5 Reference information covers routine functionality, parameter descriptions, interfaces and calling syntax as well as return values. To get this information, see Intel MKL Reference Manual first. (/opt/intel/mkl/10.0.3.020/doc/mklman.pdf)

6 user guide Some information6 user guide focuses on the usage Information needed to call Intel MKL routines from user's applications running on the Linux* OS. Linux usage of Intel MKL has its particular features, which are described in this guide, along with those that do not depend upon a particular OS. (/opt/intel/mkl/10.0.3.020/doc/userguide.pdf)

7 Some examples7

8 Examples Some examples8 There are five brief examples: 1. Compute inner product.(sequential) 2. Compute the LU factorization of a matrix. 3. Solve linear system. 4. Solve eigensystem. 5. Compute inner product.(parallel)

9 The file names of the examples Some examples9 1. mkl_blas_f95 (mkl_blas_c) 2. mkl_lapack95_f95 (mkl_lapack95_c) 3. mkl_linearsym_f95 (mkl_linearsym_c) 4. mkl_eigensym_f95 (mkl_eigensym_c) 5. mkl_blas_f95_p (mkl_blas_c_p) There are more examples in the Folder: /opt/intel/mkl/10.0.3.020/examples

10 Inner product (sequential) Vectors and PlanesIntroduction to MATLAB10 do ii = 1,n vec_a(ii) = 1.25*ii vec_b(ii) = 0.75*ii end do dot_result = ddot(n,vec_a,inca,vec_b,incb)

11 Input parameters Vectors and PlanesIntroduction to MATLAB11 n : The length of two vectors. (Here n = 5) inca : Specifies the increment for the elements of vec_a. (Here inca = 1) incb : Specifies the increment for the elements of vec_b. (Here incb = 1) vec_a : The first vector. vec_b : The second vector.

12 Output parameters Vectors and PlanesIntroduction to MATLAB12 dot_result: The final result.

13 Inner product (parallel) Vectors and PlanesIntroduction to MATLAB13 You have to reedit the makefile: FC=mpif90 MKL_INCLUDE =/opt/intel/mkl/10.0.3.020/include MKL_PATH =/opt/intel/mkl/10.0.3.020/lib/em64t EXE=blas_f95.exe blas_f: $(FC) -o $(EXE) blas_f.f90 -I$(MKL_INCLUDE) -L$(MKL_PATH) -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lguide -lpthread

14 LU factorization Vectors and PlanesIntroduction to MATLAB14 ! Define the matrix a(1,1) = 1 a(1,2) = 3 a(2,1) = 2 a(2,2) = 1 ! Compute LU factorization call dgetrf(m,n,a,lda,ipiv,info)

15 Input parameters Vectors and PlanesIntroduction to MATLAB15 a : The matrix. m : The number of rows in the matrix a. n : The number of columns in the matrix a. lda : The first dimension of a. (Here lda = 2)

16 Output parameters Vectors and PlanesIntroduction to MATLAB16 a : overwritten by L and U. The unit diagonal elements of L are skipped. ipiv: An array, dimension at least max(1,min(m, n)). The pivot indices: row i was interchanged with row ipiv(i). info : If info=0, the execution is successful. If info = -i, the i-th parameter had an illegal value. If info = i, uii is 0. The factorization has been completed, but U is exactly singular.

17 Linear System (fortran) Vectors and PlanesIntroduction to MATLAB17 ! Define the matrix a(1,1) = 1 a(1,2) = 3 a(2,1) = 2 a(2,2) = 1 ! Define the right-hand side rhs(1) = 1.0 rhs(2) = 1.0 ! Solve the linear system call dgesv(n,nrhs,a,lda,ipiv,rhs,ldb,info)

18 Input parameters Vectors and PlanesIntroduction to MATLAB18 n : The number of linear equations, that is, the order of the matrix A. (Here n = 2) rhs : Right-hand side. lda : The leading dimension of matrix A. (Here lda = 2) nrhs : The number of right-hand sides. (Here nrhs = 1)

19 Output parameters Vectors and PlanesIntroduction to MATLAB19 ipiv : An array, 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 A info : If info=0, the execution is successful. If info = -i, the i-th parameter had an illegal value If info = i, U(i, i) is exactly zero. The factorization has been completed, but the factor U is exactly singular so the solution could not be computed.

20 Eigensystem (symmetric) Vectors and PlanesIntroduction to MATLAB20 ! Define the matrixdsyev a(1,1) = 1.0 a(1,2) = 2.0 a(2,1) = 2.0 a(2,2) = 3.0 ! Call MKL function Call dsyev(jobz,uplo,dim,a,lda,eigval,work,lwork,info)

21 Input parameters Vectors and PlanesIntroduction to MATLAB21 jobz : If jobz = 'N', then only eigenvalues are computed. If jobz = 'V', then eigenvalues and eigenvectors are computed. uplo : If uplo = 'U', a stores the upper triangular part of A. If uplo = 'L', a stores the lower triangular part of A. lda : The first dimension of A. (Here lda = 2) work : a workspace array, its dimension max(1, lwork). lwork : The dimension of the array work. (lwork >= 2*lda+1)

22 Output parameters Vectors and PlanesIntroduction to MATLAB22 wigval : contains the eigenvalues of the matrix A in ascending order. info : If info=0, the execution is successful. If info = -i, the i-th parameter had an illegal value. If info = i, then the algorithm failed to converge; i indicates the number of elements of an intermediate tridiagonal form which did not converge to zero.

23 Reference Vectors and PlanesIntroduction to MATLAB23 Intel® Math Kernel Library Reference Manual Intel® Math Kernel Library for the Linux* OS User’s Guide


Download ppt "Intel Math Kernel Library Wei-Ren Chang, Department of Mathematics, National Taiwan University 2009/03/10."

Similar presentations


Ads by Google