CPU cache: how L1 and L2 exploit locality
11 steps · about 8 h 17 min · Intermediate
- How CPU Caches Work (article, 0xkato, 15 min)
Starts with an office analogy for the L1, L2, L3 and RAM lookup order, so the later numbers have something to attach to.
- What Is CPU Cache? L1, L2 and L3 Explained (article, Deepak Gupta, 12 min)
Gives typical sizes and cycle counts for each level, including why cache lines are 64 bytes.
- CPU Cache Memory Explained (tutorial, EmbeddedTechLearn, 25 min)
Covers temporal and spatial locality, write policies and hit/miss rates, including average memory access time.
- CPU Cache Memory Hierarchy: L1, L2, L3 Caches and Cache Coherency Explained (article, awjunaid, 20 min)
Adds the split L1 instruction and data caches, the miss path, and a first look at coherency across cores.
- CPU Cache Hierarchy: L1, L2, L3 Explained - TechCompare (interactive, TechCompare, 10 min)
Shows the latency gaps between levels side by side, and why sequential access is nearly free.
- Matrix Multiplication in depth (article, IIT Delhi COL729, 25 min)
Counts cache misses for naive matrix multiply, which turns the idea of locality into numbers.
- Lab 7: Data Locality and Cache blocking (tutorial, UC Berkeley CS61C, 1 h)
A hands-on lab on stride, loop order and cache blocking, using a matrix transpose.
- HW1 Caches (tutorial, UC Santa Barbara CS240A, 45 min)
An exercise that times several loop orderings of matrix multiply, so you can see locality in the runtimes.
- Spatial-Locality: cache-friendly matrix multiplication (repo, GitHub (tugbaguler), 20 min)
Walks through i-j-k versus i-k-j loop order and which matrix gains temporal or spatial locality in each.
- Matrix Multiplication: Cache-aware optimizations (blog, Arsh Sharma, 25 min)
Reports measured miss rates and speedups for loop reordering and tiling, so you can check what you predicted.
- What Every Programmer Should Know About Memory (doc, Ulrich Drepper, 4 h)
The classic deep dive into cache design, associativity and what programmers can do about it. Read the CPU caches and programmer sections first.