Anatomy of High-Performance GEMM: From Naive Loops to BLIS
Step-by-step optimization of General Matrix Multiply operations using register packing, micro-kernels, and multi-level cache blocking.
A technical journal dedicated to GEMM optimizations, cache-tiled matrix multiplication, Strassen's algorithm, Eigen/LAPACK internals, and SIMD intrinsics.
#include <vector>
// Cache-tiled matrix multiplication (GEMM) for L1/L2 locality
void tiled_gemm(const float* A, const float* B, float* C, int N, int BLOCK_SIZE) {
for (int i0 = 0; i0 < N; i0 += BLOCK_SIZE)
for (int j0 = 0; j0 < N; j0 += BLOCK_SIZE)
for (int k0 = 0; k0 < N; k0 += BLOCK_SIZE)
for (int i = i0; i < i0 + BLOCK_SIZE; ++i)
for (int k = k0; k < k0 + BLOCK_SIZE; ++k)
for (int j = j0; j < j0 + BLOCK_SIZE; ++j)
C[i * N + j] += A[i * N + k] * B[k * N + j];
}
Step-by-step optimization of General Matrix Multiply operations using register packing, micro-kernels, and multi-level cache blocking.
Using hardware-specific permutation intrinsics to transpose square matrices in-place without triggering cache line conflicts.
Comparing partial pivoting strategies, QR factorizations via Householder reflections, and avoiding catastrophic cancellation.