IT lexicon › Programming › Loop tiling

Loop tiling

Programming På svenska → Updated: 2026-11-05

Splitting a loop nest's iteration space into blocks small enough to fit in cache, and finishing one block before starting the next.

The textbook case is matrix multiplication. The naive triple loop reads a whole row and a whole column per output element, and for large matrices every value gets evicted before its next use. Cut the matrices into blocks of a few dozen elements and each block is finished while it's still hot. The number of operations is unchanged; the number of cache misses drops by an order of magnitude.

Monica Lam, Edward Rothberg and Michael Wolf analysed the effect in 1991. Compilers tile through polyhedral frameworks such as GCC's Graphite and LLVM's Polly, but the fastest BLAS libraries still tile by hand for each cache level — Kazushige Goto's GotoBLAS built a reputation on exactly that.

← Back to the lexicon