Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Parallel Computing Intel Math Kernel Library Huan-Ting Yen, Department of Mathematics, National Taiwan University 2011/07/22.

Similar presentations


Presentation on theme: "Introduction to Parallel Computing Intel Math Kernel Library Huan-Ting Yen, Department of Mathematics, National Taiwan University 2011/07/22."— Presentation transcript:

1 Introduction to Parallel Computing Intel Math Kernel Library Huan-Ting Yen, Department of Mathematics, National Taiwan University 2011/07/22

2 2011/07/22Introduction to Parallel Computing2 Parallel Computing

3 What is parallel computing? 2011/07/22Introduction to Parallel Computing3  Traditionally, software has been written for serial computation:

4 What is parallel computing? 2011/07/22Introduction to Parallel Computing4  In the simplest sense, parallel computing is the simultaneous use of multiple compute resources to solve a computational problem:

5 Resource 2011/07/22Introduction to Parallel Computing5  The compute resource  A single computer with multiple processors;  An arbitrary number of computers connected by a network;  A combination of both. Core 1Core 2Core 3 Core 4 thread 1thread 3thread 4thread 2

6 Resource 2011/07/22Introduction to Parallel Computing6  The compute resource  A single computer with multiple processors;  An arbitrary number of computers connected by a network;  A combination of both. core 4 core 3core 2core 1 several threads

7 Resource 2011/07/22Introduction to Parallel Computing7  The compute resource  A single computer with multiple processors;  An arbitrary number of computers connected by a network;  A combination of both.

8 Resource 2011/07/22Introduction to Parallel Computing8  The compute resource  A single computer with multiple processors;  An arbitrary number of computers connected by a network;  A combination of both.

9 Why use parallel computing? 2011/07/22Introduction to Parallel Computing9  The primary reasons for using parallel computing:  Save time – wall clock time  Solve larger problems  Provide concurrency (do many things at the same time)  Other reasons might include:  Taking advantage of non-local resources  Cost savings  Overcoming memory constraints

10 Amdahl’s Law 2011/07/22Introduction to Parallel Computing10  Speedup of a parallel program is limited by amount of serial works.

11 Amdahl’s Law 2011/07/22Introduction to Parallel Computing11  Speedup of a parallel program is limited by amount of serial works.

12 Flynn’s Taxonomy 2011/07/22Introduction to Parallel Computing12  Classification for parallel computers and programs Single InstructionMultiple Instruction Single Data SISD (single core CPU) MISD (very rare) Multiple Data SIMD (GPU/vector processor) MIMD (multiple core CPU)

13 Flynn’s Taxonomy 2011/07/22Introduction to Parallel Computing13  Classification for parallel computers and programs SISDSIMD

14 Flynn’s Taxonomy 2011/07/22Introduction to Parallel Computing14  Classification for parallel computers and programs MISDMIMD

15 2011/07/22Introduction to Parallel Computing15 Intel Math Kernel Library

16 Overview 2011/07/22Intel MKL Quickstart16  The Intel® Math Kernel Library (Intel® MKL) provides Fortran routines and functions that perform a wide variety of operations on vectors and matrices including sparse matrices. The library also includes fast Fourier transform (FFT) functions, as well as vector mathematical and vector statistical functions with Fortran and C interfaces.  The versions of Intel MKL intended for Windows* and Linux* operating systems also include ScaLAPACK software and Cluster FFT software for solving respective computational problems on distributed-memory parallel computers.

17 Intel MKL: Intel Math Kernel Library 2011/07/22Intel MKL Quickstart17  Functionality  BLAS and Sparse BLAS Routines  LAPACK Routines: Linear Equations  LAPACK Routines: Eigenvalue Problems  ScaLAPACK  Sparse Solver Routines  Fast Fourier Transforms  Cluster Fast Fourier Transforms

18 System Requirements (Hardware) 2011/07/22Intel MKL Quickstart18  Hardware:  Intel® Core™ processor family  Intel® Xeon® processor family  Intel® Pentium® 4 processor family  Intel® Pentium® lll processor  Intel® Pentium® processor (300 MHz or faster)  Intel® Celeron® processor  A MD Athlon* and Opteron* processors  How do you know that information about the CPUs ?  $ cat /proc/cpuinfo

19 System Requirements (Software) 2011/07/22Intel MKL Quickstart19  Following is the list of supposed operating system :  Red Hat* Enterprise Linux* 3, 4, 5  Red Hat* Fedora* 9  Debian * GNU/Linux 4.0  Ubuntu* 8.04  How do you know that information about the operating system?  $ cat /etc/*release  Following is the list of supposed C/C++ and Fortran compilers :  Intel® Fortran Compiler 10.1 for Linux*  Intel® C++ Compiler 10.1 for Linux*  GNU Compiler Collection ( gcc, g77, gfortran 4.2.0 )

20 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart20  Tools & Downloads  http://software.intel.com/en-us/ (google “intel software” ) http://software.intel.com/en-us/

21 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart21

22 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart22

23 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart23

24 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart24

25 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart25

26 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart26

27 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart27  user@host:~/software$ wget “URL”  user@host:~/software$ ll  $ tar –zxvf l_mkl_p_10.2.x.yyy.tar.gz

28 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart28  cd l_mkl_p_10.2.x.yyy ./install.sh

29 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart29

30 Installing Intel MKL on a Linux* System 2011/07/22Intel MKL Quickstart30

31 31 Intel MKL Quickstart Some Examples

32 Example 2011/07/22Intel MKL Quickstart32  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

33 Example 2011/07/22Intel MKL Quickstart33  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

34 Ex1. The complex dot product ( ) 2011/07/22Intel MKL Quickstart34 #include #include "mkl_blas.h” #define N 5 typedef struct{ double re; double im; }mkl_complex; int main() { int n, incx = 1, incy = 1, i; mkl_complex x[N], y[N], res; void zdotc(); n = N; for( i = 0; i < n; i++ ){ x[i].re = (double)i; x[i].im = (double)i * 2.0; y[i].re = (double)(n - i); y[i].im = (double)i * 2.0; } zdotc( &res, &n, x, &incx, y, &incy ); printf( “The complex dot product is: ( %6.2f, %6.2f )\n", res.re, res.im ); return 0; }

35 ?dotc 2011/07/22Intel MKL Quickstart35  Computes a dot product of a conjugate vector with another vector.  Description : The routine is declared in  Fortran77 : mkl_blas.fi  Fortran95 : blas.f90  C : mkl_blas.h  Input Parameters ( zdotc(&res,&n,x,&incx,y,&incy) )  n : The length of two vectors.  incx : Specifies the increment for the elements of x  incy : Specifies the increment for the elements of y  output Parameters ( zdotc(&res,&n,x,&inca,y,&incb) )  res : The final result

36 Makefile (Sequential) 2011/07/22Intel MKL Quickstart36 Test : blas_c CC = icc MKL_HOME = /home/opt/intel/mkl/10.2.2.025 MKL_INCLUDE = $(MKL_HOME)/include MKL_PATH = $(MKL_HOME)/lib/em64t EXE = blas_c.exe blas_c: $(CC) -o $(EXE) blas_c.c -I$(MKL_INCLUDE) -L$(MKL_PATH) -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread

37 Makefile (Parallel) 2011/07/22Intel MKL Quickstart37 Test = blas_c CC = icc MKL_HOME = /home/opt/intel/mkl/10.2.2.025 MKL_INCLUDE = $(MKL_HOME)/include MKL_PATH = $(MKL_HOME)/lib/em64t EXE = blas_c.exe blas_c: $(CC) -o $(EXE) blas_c.c -I$(MKL_INCLUDE) -L$(MKL_PATH) -Wl,--start-group -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thred -Wl,--end-group –liomp5 -lpthread

38 ?dotc 2011/07/22Intel MKL Quickstart38  Computes a dot product of a conjugate vector with another vector.  Description : The routine is declared in  Fortran77 : mkl_blas.fi  Fortran95 : blas.f90  C : mkl_blas.h  Input Parameters ( zdotc(&res,&n,x,&inca,y,&incb) )  n : The length of two vectors.  incx : Specifies the increment for the elements of x  incy : Specifies the increment for the elements of y  output Parameters ( zdotc(&res,&n,x,&inca,y,&incb) )  res : The final result

39 BLAS Routines 2011/07/22Intel MKL Quickstart39  Routines Naming Conventions  BLASB routine names have the following structure: ()  The filed indicates the data type: s real, single precision c complex, single precision d real, double precision z complex, double precision  The filed indicates the data type: c conjugated vector u unconjugated vector g Givens rotation.

40 BLAS Routines 2011/07/22Intel MKL Quickstart40  Routines Naming Conventions  BLASB routine names have the following structure: ()  In BLAS level 2 and 3, filed indicates the matrix type: ge general matrix gb general band matrix sy symmetric matrix sb symmetric band matrix he Hermitian matrix hb Hermitian band matrix tr triangular matrix tb triangular band matrix

41 BLAS Level 1 Routines 2011/07/22Intel MKL Quickstart41 RoutineData TypeDescription ?asums, d, sc, dz Sum of vector magnitudes ?axpys, d, c, z Scalar-vector product ?copys, d, c, z Copy vector ?dots, d Doc product ?dotcc, z Doc conjugated ?nrm2s, d, sc, dz Vector 2-norm (Euclidean norm) ?rotgs, d, cs, zd Givens rotation of points ?rots, d, cs, zd Plane rotation of points ?scals, d, c, z, cs, zd Vector-scalar product ?swaps, d, c, z Vector-vector swap i?maxs, d, c, z Index of the maximum absolute value element of a vector

42 Example 2011/07/22Intel MKL Quickstart42  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

43 Ex2-1. Matrix-vector product 2011/07/22Intel MKL Quickstart43 #include "mkl_blas.h” int main() { int m, n, incx, incy, lda, idxi, idxj; double alpha, beta, *x, *y, *A ; char trans; m = 3; n = 3; incx = 1; incy = 1; lda = m; alpha = 1.0; beta = 1.0; trans = 'n’; x = (double*)malloc(sizeof(double)*n); y = (double*)malloc(sizeof(double)*n); A = (double*)malloc(sizeof(double)*m*n);

44 Ex2-2. Matrix-vector product 2011/07/22Intel MKL Quickstart44 for( idxi = 0; idxi < n; idxi++ ){ *(x+idxi) = 1.0; *(y+idxi) = 1.0; } for( idxi = 0; idxi < m; idxi++ ) for( idxj = 0; idxj < n; idxj++) *(A+idxi*m+idxj) = (double)(idxi+1) + idxj; dgemv(&trans, &m, &n, &alpha, A, &lda, x, &incx, &beta, y, &incy); return 0; }

45 ?gemv 2011/07/22Intel MKL Quickstart45  Computes a matrix-vector product using a general matrix.  Description : The routine is declared in  Fortran77 : mkl_blas.fi  Fortran95 : blas.f90  C : mkl_blas.h  Input Parameters dgemv(&trans,&m,&n,&alpha,A,&lda,x,&incx,&beta,y,&incy)  trans : if trans = ‘N’, ‘n’, then if trans = ‘T’, ‘t’, then if trans = ‘C’, ‘c’, then  m : The number of rows of the matrix A.

46 ?gemv 2011/07/22Intel MKL Quickstart46  Input Parameters  n : The number of columns of the matrix  lda : The first dimension of matrix, lda = max(1,m)  incx : Specifies the increment for the elements of x  incy : Specifies the increment for the elements of y  output Parameters  y : Updated vector y.

47 Ex2. Result Vectors and PlanesIntroduction to MATLAB47

48 BLAS Level 2 Routines 2011/07/22Intel MKL Quickstart48 RoutineData TypeDescription ?gemvs, d, c, z Matrix-vector product using a general matrix ?gbmvs, d, c, z Matrix-vector product using a general band matrix ?symvs, d Matrix-vector product using a symmetric matrix ?sbmvs, d Matrix-vector product using a symmetric band matrix ?hemvc, z Matrix-vector product using a Hermitian matrix ?hbmvc, z Matrix-vector product using a Hermitian band matrix ?trmvc, z Matrix-vector product using a triangular matrix ?tbmvs, d, sc, dz Matrix-vector product using a triangular band matrix

49 Example 2011/07/22Intel MKL Quickstart49  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

50 Ex3-1. Matrix-Matrix product 2011/07/22Intel MKL Quickstart50 #include "mkl_blas.h” int main() { int m, n, k, lda, ldb, ldc, idxi, idxj; double alpha, beta, *A, *B, *C ; char transa, transb; m = 3; n = 3; k = 3; lda = m; ldb = k; ldc = m; alpha = 1.0; beta = 1.0; transa = 'n’; transb = 'n’;

51 Ex3-2. Matrix-vector product 2011/07/22Intel MKL Quickstart51 A = (double*)malloc(sizeof(double)*m*n); B = (double*)malloc(sizeof(double)*m*n); C = (double*)malloc(sizeof(double)*m*n); for( idxi = 0; idxi < m; idxi++ ) for( idxj = 0; idxj < n; idxj++) { *(A+idxi*m+idxj) = (double)(idxi+1) + idxj; *(B+idxi*m+idxj) = (double)(idxi+1) + idxj; *(C+idxi*m+idxj) = (double)(idxi+1) + idxj; } dgemm(&transa, &transb, &m, &n, &k, &alpha, A, &lda, B, &ldb, &beta, C, &ldc); return 0; }

52 ?gemm 2011/07/22Intel MKL Quickstart52  Input Parameters  k : The number of columns of the matrix and the number of rows of the matrix.  lda : When transa=‘N’ or ‘n’, then lda = max(1,m), otherwise lda=max(1,k).  ldb : When transa=‘N’ or ‘n’, then ldb = max(1,k), otherwise lda=max(1,n).  ldc : The first dimension of matrix, ldc = max(1,m)  output Parameters  C : Overwritten by m- by -n matrix.

53 Ex3. Result Vectors and PlanesIntroduction to MATLAB53

54 BLAS Level 3 Routines 2011/07/22Intel MKL Quickstart54 RoutineData TypeDescription ?gemms, d, c, z Matrix-matrix product of general matrices ?hemvc, z Matrix-matrix product of Hermitian matrices ?symms, d, c, z Matrix-matrix product of symmetric matrices ?trmms, d, sc, dz Matrix-matrix product of triangular matrices

55 Example 2011/07/22Intel MKL Quickstart55  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

56 Ex4. LU Factorization 2011/07/22Intel MKL Quickstart56 #include "mkl_lapack.h” int main() { int m, n, lda, info, idxi, idxj, *ipiv; double *A; m = 3; n = 3; lda = m; ipiv = (int*)malloc(sizeof(int)*m); A = (double*)malloc(sizeof(double)*m*n); *(A+0)=1; *(A+1)=2; *(A+2)=6; *(A+3)=-2; *(A+4)=3; *(A+5)=5; *(A+6)=4; *(A+7)=8; *(A+8)=1; dgetrf(&m, &n, A, &lda,ipiv, &info); return 0; }

57 ?getrf 2011/07/22Intel MKL Quickstart57  Description : The routine is declared in  Fortran77 : mkl_lapack.fi  Fortran95 : lapack.f90  C : mkl_lapack.h  Input Parameters  m : The number of columns of the matrix.  n : The number of rows of the matrix.  lda : The first dimension of matrix.  A : Array, REAL for sgetrf DOUBLE PRECISION for dgetrf COMPLEX for cgetrf DOUBLE COMPLEX for zgetrf.

58 ?getrf 2011/07/22Intel MKL Quickstart58  output Parameters  A : Overwritten by L and U. The unit diagonal elements of L are not stored.  ipiv : An integer array, dimension at least max(1,min(m,n)). The pivot indices ; row i is interchanged with row ipiv(i)  info : Integer. If info=0, the execution is successful. If info=-i, the i -th parameter had an illegal value. If info=i, The factorization has been completed, but U is singular.

59 Ex4-1. Result Vectors and PlanesIntroduction to MATLAB59

60 Ex4-2. Result Vectors and PlanesIntroduction to MATLAB60

61 LAPACK Computational Routines 2011/07/22Intel MKL Quickstart61 general matrix sysmmetric indefinite sysmmetric positive- definite triangular matrix Factorize matrix ?getrf?sytrf?potrf Solve linear system with a factored matrix ?getrs?sytrs?potrs?trtrs Condition number ?gecon?sycon?pocon?trcon Compute the inverse matrix using the factorization ?getri?sytri?potri?trtri

62 LAPACK Routines: Linear Equations 2011/07/22Intel MKL Quickstart62 To solve a particular problem, you can call two or more computational routines or call a corresponding driver routines that combines several tasks in one call. For example, to solve a system of linear equation with a general matrix, call ?getrf (LU factorization) and then ?getrs (computing the solution). Alternatively, use the driver routine ?gesv that performs all these tasks in one call.

63 Example 2011/07/22Intel MKL Quickstart63  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

64 Ex5-1. Solve the Linear Eqation 2011/07/22Intel MKL Quickstart64 #include #include "mkl_lapack.h” int main() { int n, nrhs, lda, ldb, info, idxi, idxj, *ipiv; double *A, *b; n = 3; nrhs = 1; lda = n; ldb = n; ipiv = (int*)malloc(sizeof(int)*n); A = (double*)malloc(sizeof(double)*n*n); b = (double*)malloc(sizeof(double)*n); for( idxi = 0; idxi < n; idxi++ ) for( idxj = 0; idxj < n; idxj++) *(A+idxi*n+idxj) = (double)(idxi+1) + idxj;

65 Ex5. Solve the Linear Eqation 2011/07/22Intel MKL Quickstart65 *(b+0) = 6; *(b+1) = 9; *(b+2) = 12; dgesv(&n, &nrhs, A, &lda,ipiv, b, &ldb, &info); return 0; }

66 ?gesv 2011/07/22Intel MKL Quickstart66  Input Parameters  nrhs : The number of columns of the matrix.  Output Parameters  A : Overwritten by the factor L and U from the factorization of.  b : Overwritten by the solution matrix.

67 Ex5. Result Vectors and PlanesIntroduction to MATLAB67

68 Example 2011/07/22Intel MKL Quickstart68  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

69 Ex6-1. Solve the Eigen Eqation 2011/07/22Intel MKL Quickstart69 #include "mkl_lapack.h” int main() { int n, lda, lwork, ldvl, ldvr, info, idxi, idxj; double *wr, *wi, *A, *work, *vl, *vr; char jobvl, jobvr; n = 3; lda = n; ldvl = 1; ldvr = n; lwork = 4*n; // not 3*n jobvl = ‘N’; jobvr = ‘V’; A = (double*)malloc(sizeof(double)*n*n); wr = (double*)malloc(sizeof(double)*n); wi = (double*)malloc(sizeof(double)*n); vl = (double*)malloc(sizeof(double)*ldvl*n); vr = (double*)malloc(sizeof(double)*ldvr*n); work = (double*)malloc(sizeof(double)*lwork);

70 Ex6-2. Solve the Eigen Eqation 2011/07/22Intel MKL Quickstart70 *(A+0) = 2; *(A+1) = -1; *(A+2) = 0; *(A+3) = -1; *(A+4) = 2; *(A+5) = -1; *(A+6) = 0; *(A+7) = -1; *(A+8) = 2; dgeev(&jobvl, &jobvr, &n, A, &lda, &wr, &wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info); return 0; }

71 ?geev 2011/07/22Intel MKL Quickstart71  Input Parameters  jobvl : If jobvl=‘N’, the left eigenvalues of A are not computed. If jobvl=‘V’, the left eigenvalues of A are computed.  jobvr : If jobvr=‘N’, the right eigenvalues of A are not computed. If jobvr=‘V’, the right eigenvalues of A are computed.  work : A workspace array, its dimension max(1, lwork).  lwork : The dimension of the array work. lwork ≥ max(1,3n), lwork < max(1,4n) (for real).  ldvl, ldvr : The leading dimension of the output array vl and vr, respectively.

72 ?geev 2011/07/22Intel MKL Quickstart72  Output Parameters  wr, wi : Contain the real and imaginary parts, respectively, of the computed eigenvalue.  vl, vr : If jobvl = ‘V’, the left eigenvectors u(j) are stored one after another in the columns of vl, in the same order as their eigenvalues. If jobvl = ‘N’, vl is not referenced. If the j -th eigenvalue is real, then u(j) = vl(:,j), the j -th column of vl.  info : info=0, the execution is successful. info=-i, the i -th parameter had an illegal value. info= i, then the QR algorithm failed to compute all the eigenvalues, and no eigenvector have been computed.

73 Ex6. Result Vectors and PlanesIntroduction to MATLAB73

74 LAPACK Computational Routines 2011/07/22Intel MKL Quickstart74  Orthogonal Factorizations ( QR, QZ )  Singular Value Decomposition  Symmetric Eigenvalue Problems  Generalized Symmetric-Definite Eigenvalue Problems  Nonsymmetric Eigenvalue Problems  Generalized Nonsymmetric Eigenvalue Problems  Generalized Singular Value Decomposition

75 LAPACK Driver Routines 2011/07/22Intel MKL Quickstart75  Linear Least Squares (LLS) Problems  Generalized LLS Problems  Symmetric Eigenproblems  Nonsymmetric Eigenproblems  Singular Value Decomposition  Generalized Symmetric Definite Eigenproblems  Generalized Nonsymmetric Eigenproblems

76 Example 2011/07/22Intel MKL Quickstart76  Brief examples to  BLAS Level 1 Routines (vector-vector operations)  BLAS Level 2 Routines (matrix-vector operations)  BLAS Level 3 Routines (matrix-matrix operations)  Compute the LU factorization of a matrix (LAPACK)  Solve linear system (LAPACK)  Solve eigen system (LAPACK)  Fast Fourier Transforms

77 Five Stage Usage Model for Computing FFT 2011/07/22Intel MKL Quickstart77  Allocate a fresh descriptor for the problem with a call to the DftiCreateDescriptor function. (precision, rank, sizes, scaling factor, …)  Optionally adjust the descriptor configuration with a call to the DftiSetValue function.  Commit the descriptor with a call to the DftiCommitDescriptor function.  Compute the transform with a call to the DftiComputeForward / DftiComputeBackward function.  Deallocate the descriptor with a call to the DftiFreeDescriptor function.

78 Ex7-1. Three-Dimensional Complex FFT 2011/07/22Intel MKL Quickstart78 #include "mkl_dfti.h” #define m 1000 #define n 1000 #define k 1000 typedef struct { double re; double im; } mkl_complex; int main() { int idxi, idxj, idxk; double backward_scale; MKL_LONG status, length[3]; mkl_complex *vec_src, *vec_tmp, *vec_dst; DFTI_DESCRIPTOR_HANDLE handle = 0;

79 Ex7-2. Three-Dimensional Complex FFT 2011/07/22Intel MKL Quickstart79 x_src = (mkl_complex*)malloc(sizeof(mkl_complex)*m*n*k); x_tmp = (mkl_complex*)malloc(sizeof(mkl_complex)*m*n*k); x_dst = (mkl_complex*)malloc(sizeof(mkl_complex)*m*n*k); length[0] = m; length[1] = n; length[2] = k; memset(x_src, 0, sizeof(sizeof(mkl_complex)*m*n*k)); memset(x_tmp, 0, sizeof(sizeof(mkl_complex)*m*n*k)); memset(x_dst, 0, sizeof(sizeof(mkl_complex)*m*n*k)); for(idxk=0; idxk<k; idxk++) for(idxj=0; idxj<n; idxj++) for(idxi=0; idxi<m; idxi++) { (x_src+idxk*k*n+idxj*n+idxi)->re=1.0; (x_src+idxk*k*n+idxj*n+idxi)->im=0.0; }

80 Ex7-3. Three-Dimensional Complex FFT 2011/07/22Intel MKL Quickstart80 status = DftiCreateDescriptor( &handle, DFTI_DOUBLE, DFTI_COMPLEX, 3, length ); if(status && !DftiErrorClass(status, DFTI_NO_ERROR)) { printf("Error : %s\n", DftiErrorMessage(status)); printf("TEST FAILED : DftiCreatDescriptor(&hand,...)\n"); } status = DftiSetValue( handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE ); status = DftiCommitDescriptor( handle ); status = DftiComputeForward( handle, vec_src, vec_tmp ); backward_scale = 1.0/((double)m*n*k); status = DftiSetValue( handle, DFTI_BACKWARD_SCALE, backward_scale ); status = DftiCommitDescriptor( handle ); status = DftiComputeBackward( handle, vec_tmp, vec_dst); status = DftiFreeDescriptor( &handle ); return 0; }

81 FFT Functions 2011/07/22Intel MKL Quickstart81 Function NameOperation DftiCreateDescriptor Allocates memory for the descriptor data structure and preliminarily initializes it. DftiCommitDescriptor Performs all initialization for the actual FFT computation. DftiCopyDescriptor Copies an existing descriptor. DftiFreeDescriptor Frees memory allocated for a descriptor. DftiComputeForward Computes the forward FFT. DftiComputeBackward Computes the backward FFT. DftiSetValue Sets one particular configuration parameter with the specified configuration value. DftiGetValue Gets the value of one particular configuration parameter.

82 82 Intel MKL Quickstart Reference  Web site form LLNL tutorials (https://computing.llnl.gov/tutorials/parallel_comp/)https://computing.llnl.gov/tutorials/parallel_comp/  Intel® Math Kernel Library Reference Manual (mklman.pdf)  Intel® Math Kernel Library for the Linux OS User ’ s Guide (userguide.pdf) Reference

83 Vectors and PlanesIntroduction to MATLAB83


Download ppt "Introduction to Parallel Computing Intel Math Kernel Library Huan-Ting Yen, Department of Mathematics, National Taiwan University 2011/07/22."

Similar presentations


Ads by Google