180 likes | 245 Views
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
E N D
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: N2 operations that look like “ab+cd” that all can be done independently • What is the most efficient way? Scientific Libraries BWUPEP2011, UIUC, May 29 - June 10 2011
Answers to the previous questions Lazy answer #1: You don’t need to do either! • What is the most efficient way? Lazy answer #2: It depends. How would/did you program it? How about parallelizing it? Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10 2011
Explanation of Lazy Answer #1 The solution of a large number of very smart people over many years Your solution Solution Quality: Don’t reinvent the wheel Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10 2011
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
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
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
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
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
Atlas Performance Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10 2011
Lapack Eigenvector Eigenvalue = 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
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
Beginner’s Guide to LAPACK #1 RULE – Documentation is your friend!! 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
Beginner’s Guide to LAPACK Data type + Matrix Type + Problem Not all subroutines have handy naming scheme. USE DOCUMENTATION • 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
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
Leading dimensions? You have this: You want to perform an operation on this: LDA = 3 M=2 N=2 LDA = M This occurs the most Supercomputing in Plain English: Apps & Par Types BWUPEP2011, UIUC, May 29 - June 10 2011
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’tattempt 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
Preview: Next Week ScaLAPACK 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