intro to scientific libraries

18
Intro to Intro to Scientific Libraries Scientific Libraries Blue Waters Undergraduate Petascale Education Program May 29 – June 10 2011

Upload: dean

Post on 22-Jan-2016

26 views

Category:

Documents


0 download

DESCRIPTION

Intro to Scientific Libraries. Blue Waters Undergraduate Petascale Education Program May 29 – June 10 2011. Matrix Multiplication. How would/did you program it? How about parallelizing it? -Hint: N 2 operations that look like “ ab+cd ” that all can be done independently - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Intro to  Scientific Libraries

Intro to Intro to Scientific LibrariesScientific Libraries

Blue Waters Undergraduate Petascale Education Program

May 29 – June 10 2011

Page 2: Intro to  Scientific Libraries

Scientific LibrariesBWUPEP2011, UIUC, May 29 - June 10 2011 2

Matrix Multiplication How would/did you program it? How about parallelizing it?

-Hint: N2 operations that look like “ab+cd” that all can be done independently

What is the most efficient way?

Page 3: Intro to  Scientific Libraries

Answers to the previous questions How would/did you program it? How about parallelizing it?

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 3

Lazy answer #1: You don’t need to do either!

What is the most efficient way?

Lazy answer #2: It depends.

Page 4: Intro to  Scientific Libraries

Explanation of Lazy Answer #1 Solution Quality:

Don’t reinvent the wheel

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 4

The solution of a large number

of very smart people over many years

Your solution

Page 5: Intro to  Scientific Libraries

Scientific Libraries Loose Definition – A collection of mathematical optimized

for various data types, computer architectures, numeric types, and scientific fields of study.

Common example:

Lapack- linear algebra library

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 5

Page 6: Intro to  Scientific Libraries

How to identify your matrix General Matrix – Nothing too special going on with it Banded Matrix – A lines of data going diagonally down the

matrix.

Tri-diagonal matrix- A 3-width

banded matrix

Symmetric matrix-

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 6

Page 7: Intro to  Scientific Libraries

The Sparse Matrix A larger matrix that is mostly empty. A good rule of thumb

is approximately 90% - 95% empty. The opposite of a sparse matrix is a dense matrix.

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 7

Page 8: Intro to  Scientific Libraries

BLAS Basic Linear Algebra System Fundamental level of linear algebra libraries Various highly optimized implementations by vendors Many other libraries built on top of BLAS Create your own optimized implementation using ATLAS Three levels:

Level 1- Vector-vector operations -

Level 2- Matrix-vector operations -

Level 3- Matrix-matrix operations –

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 8

Page 9: Intro to  Scientific Libraries

ATLAS Automatically Tuned Linear Algebra Software Performs a series of timed tests upon installation. These

tests are used to tune the libraries for the individual system. Substantially faster on many systems.

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 9

Page 10: Intro to  Scientific Libraries

Atlas Performance

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 10

Page 11: Intro to  Scientific Libraries

Lapack Written on top of Basic Linear Algebra Subprograms

(BLAS) Incorporates/retools EISPACK (eigenvalues) and LINPACK

(least squares) Optimized for most modern shared memory architectures

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 11

Eigenvalue

=

Eigenvector

Page 12: Intro to  Scientific Libraries

Why LAPACK? Widely available. Lots of documentation and examples. Easy to use. Mostly preinstalled and tuned on most

computers. Many versions are tuned for shared memory architectures. Since it is built on top of your BLAS installation, it’ll

perform at least as well as BLAS.

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 12

Page 13: Intro to  Scientific Libraries

Beginner’s Guide to LAPACK

First step: Install LAPACK

-May involve installing BLAS first (Optional activity!)

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 13

#1 RULE – Documentation is your friend!!

Page 14: Intro to  Scientific Libraries

Beginner’s Guide to LAPACK Second step- Look up what you want to do.

-Handy naming scheme:

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 14

GE General Matrix

DI Diagonal Matrix

GB General Band Matrix

GT Tridiagonal Matrix

HB Hermitian Band matrix

SY Symmetric matrix

TRF Factorize

TRS Solve

TRI Invert

RFS Error bounds

S Real

D Double

C Complex

Z Complex Double

Data type + Matrix Type + Problem

Not all subroutines have handy naming scheme. USE DOCUMENTATION

Page 15: Intro to  Scientific Libraries

EXAMPLES Simple LAPACK call- DGEMM A bunch of calls repeated 1000 times Bonus demo-Difficult part of

libraries!

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 15

Page 16: Intro to  Scientific Libraries

Leading dimensions?

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 16

You have this:

You want to perform an operation on this:

LDA = M

This occurs the most

LDA = 3M=2N=2

Page 17: Intro to  Scientific Libraries

General “Don’t”s Don’t invert a matrix if it can be avoided. It is

computationally very expensive. Figure out a way around it. Don’t write your own solvers. If it is a common

mathematical operation, someone else most likely spent a lot of time and effort solving for the most efficient method.

Don’t attempt to use a library without consulting the documentation and attempting a few example problems.

Don’t attempt to program a solution (especially with libraries) if you don’t understand the problem’s mathematics/science!

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 17

Page 18: Intro to  Scientific Libraries

Preview: Next Week DOE ACTs collection:

2nd lazy answer- How do we decide what to use to optimize efficiency?

Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10

2011 18

ScaLAPACK