BLAS's Three Levels: From Vector to Matrix Power
The Basic Linear Algebra Subprograms (BLAS) evolved through three distinct levels: Level 1 (vector operations) emerged in the 1970s, followed by Level 2 (matrix-vector operations) in the mid-1980s, and crucially, Level 3 (matrix-matrix operations) in the late 1980s, which was designed to exploit CPU cache hierarchies for high performance in libraries like LAPACK.
The top 3
- BLAS Levels: Work vs. Data for Max Speed: BLAS Level 1 (vector-vector operations) involves O(N) data and O(N) work. Level 2 (matrix-vector operations) scales to O(N^2) data and O(N^2) work. Level 3 (matrix-matrix operations) performs O(N^3) work on just O(N^2) data, making it highly efficient for cache utilization and thus providing superior performance on modern architectures.
- Core Operations: What Each BLAS Level Does: Level 1 BLAS handles vector-vector operations like scaling (xSCAL), copying (xCOPY), and dot products (xDOT). Level 2 focuses on matrix-vector operations such as general matrix-vector multiplication (xGEMV) and rank-1 updates (xGER). Level 3, the most powerful, features matrix-matrix products (xGEMM) and various symmetric/Hermitian matrix operations.
- Level 3's Cache Power: The Blocked Algorithm Advantage: The main performance boost from Level 3 BLAS comes from its ability to exploit cache hierarchies. By performing matrix-matrix operations, it enables block-partitioned algorithms that maximize data reuse within faster cache memory, significantly reducing the need to access slower main memory and outperforming Level 1 and 2 operations for large datasets.
Sources
Open the full topic