
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Some slides from
James Lambers
, Stanford
-^
Three levels:
-^
Level 1: Vector operations
-^
Level 2: Matrix-Vector operations
-^
Level 3: Matrix-Matrix operations
Originally written in F77, the standard has evolved to containF77,F95,C,C++ libraries, each with their own version of the callingprogram. The dcopy routine is used to copy two vectors and is givenby: f_dcopy for fortran users and c_dcopy for C users.
-^
BLAS 1 was originally designed for vector processors. BLAS 2 and 3were designed for cache-based computers
-^
Linear equation and linear least squares solvers
-^
Based on level 1 routines in BLAS
-^
Computes eigenvalues and eigenvectors
-^
Originally designed to extend LINPACK and EISPACK on shared memoryvector and parallel processors
-^
Also implements highly-tuned system-dependend BLAS libraries, usingBLAS levels 2 and 3 wherever possible
-^
Designed to extend LAPACK routines to work on distributed memoryparallel machines
-^
Uses BLACS (Basic Linear Algebra Communications Subprograms) forinterprocessor communication
-^
-^
Run a performance tuner which stores information about particular machineto optimize BLAS routines
-^
Performance tuner can take days because it creates system-specificversions of all BLAS routines
-^
http://www.icsi.berkeley.edu/~bilmes/phipac/
-^
System-specific information is placed into the design of one specificsubroutine which can be called by all BLAS routines.
-^
http://www.netlib.org/atlas/
-^
System-specific information created at runtime using a "planner", whichstores information used by "executor" functions during program execution
-^
http://www.fftw.org
-^
Intel Math Kernel Library (MKL)
-^
http://www.intel.com/software/products/mkl/
HP MLIB (Mathematical Software Library)
-^
IBM ESSL (Engineering and Scientific Subroutine Library)
-^
SUN Performance Library
-^
Visual Numerics' IMSL (Mathematical and Statistical Library)
-^
http://www.vni.com
Numerical Algorithms Groups' Numerical Libraries
-^
http://www.nag.co.uk
Prefix
Fortran type
Real
Double precision
Complex
Double precisioncomplex
Type code
Matrix type
General full
Symmetric
Hermitian
Triangular
General banded
Symmetric banded
CME212 – Introduction to Large-Scale Computing in Engineering
High Performance Computing and Programming
-^
Two-way loop unrolling: for(i=0;i<nend;i+=2)
ddot1+=x[i]y[i];ddot2+=x[i+1]y[i+1]; }
No unrolling: for(i=0;i<N;i++)
ddot+=x[i]*y[i];
-^
Level 2 routines consist of 2 loops and include matrixcopy, matrix transpose, and matrix-vector routines.
-^
Matrix copy: dge_copy^ Performs well because of unit stride on inner-most loop:^ for(i=0;i<N;i++)
gcc –O2 (1024 X 1024 int)Copy: 707.31 Mb/sTranspose: 54.59 Mb/s
1-d
blocks
(a
and
b
ints):
int
en
bsize*(n/bsize);
for(jj=0;jj<en;jj+=bsize)
for(i=0;i<n;i++)
for(j=jj;j<jj+bsize;jj++)
b[i][j]=a[j][i];
-^
After i=0 inner loop (assuming 32-byte cache blocks):^ – 8*bsize elements of a in L1 cache (a[0:bsize-1][0:7])
-^
Next 7 loops in i will hit a[][] data
0 700 600 500 400 300 200 100
1
10
100
1000
bsize
Mb/s
Note:32 x 32 ints=4096 bytes45 x 45 ints=8100 bytesL1 = 16 kb
16 kb
Peak throughput occurs when bsize=45(when two 45x45 matrices fit into L1 cache!)
-^
This is termed
out-of-place matrix transpose
-^
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
temp
a[i][j];
a[i][j]
a[j][i];
a[j][i]
temp;
Exchange
Move along a column and swap elements.suffers from possible cache thrashing when n is a power of 2 since a[in+j]and a[jn+i] can map to same cache location