文档介绍:Performance libraries:
Math Kernel Library
2003年3月
Agenda
介绍
目的
MKL的内容
性能特性
有资源限制的优化
线程
使用函数库
BLAS回顾
目的
性能,性能,性能!
MKL是Intel为科学和工程计算设计的数学库
开始,只包含BLAS和 FFT
定位:
Solvers (BLAS, LAPACK)
特征向量/特征值 solvers(BLAS, LAPACK)
一些量子化学的需要(dgemm)
PDEs, 信号处理, 地震, solid-state physics (FFTs)
General scientific, financial (vector transcendental functions VML)
针对现在和将来的Intel处理器进行优化
目的– don’ts
But don’t use MKL on …
Don’t use MKL on “small” counts
Don’t call vector math functions on small n
X’
Y’
Z’
W’
X
Y
Z
W
=
4x4
Transformation
matrix
几何变换
*这些情况可以使用IPP
MKL的内容
BLAS (Basic Linear Algebra Subroutines)
Level 1 BLAS – vector-vector operations
15 function types
48 functions
Level 2 BLAS – matrix-vector operations
26 function types
66 functions
Level 3 BLAS – matrix-matrix operations
9 function types
30 functions
Extended BLAS – level 1 BLAS for sparse vectors
8 function types
24 functions
MKL Contents
LAPACK (linear algebra package)
Solvers & eigensolvers Many hundreds of routines total!
Total user callable + support routines > 1000
FFTs (fast fourier transforms)
one & two dimensional
with & without frequency ordering (bit reversal)
VML (vector math library)
Set of vectorized transcendental functions
Most of libm functions, but faster
MKL的内容
大多数 MKL函数具有Fortran接口
源于高性能计算
BLAS, LAPACK 等函数库大多数用Fortran实现
Cblas接口–为了方便C/C++程序员调用BLAS
MKL的内容- 环境
支持Intel和CVF Fortran 编译器
支持 Linux 和 Windows 操作系统
静态和动态链接库
支持所有处理器– 32-bit and 64-bit
大量的测试和例程
大量的文档 MKL Index
有资源限制的优化
所有优化的目标是:最高的速度
耗尽系统的一项或多项资源: (尽量利用资源)
CPU –寄存器短缺是较大的挑战
Cache –尽可能将数据保持在Cache中
内存带宽–最低限度的访问内存
Computer –尽可能利用所有处理器
System –尽可能利用所有结点(将来)
线程
大多数 MKL 函数支持多线程,但是
level 1, level 2 BLAS 的多线程效果不大( O(n) )
很多函数可以支持多线程
Level 3 BLAS ( O(n3) )
LAPACK ( O(n3) )
FFTs ( O(n log(n) )
VML? Depends on processor and function
所有多线程通过 OpenMP实现
所有MKL函数可以很安全的设计和编译成多线程