Paper: Roofline: An Insightful Visual Performance Model (Williams, Waterman, Patterson, CACM 2009)
The roofline model (Williams, Waterman, Patterson, 2009) is the single most useful back-of-the-envelope tool for reasoning about performance. It answers one question that the spec sheet never does: given a kernel, is it limited by how fast the hardware can compute, or by how fast it can move data?
Skip to the playground if you just want to drag the point around. The short version is below.
A datasheet tells you the peak compute throughput (FLOP/s) and the peak memory bandwidth (bytes/s). Those are two separate ceilings, and almost no real kernel hits the first one. The reason is that every floating-point operation needs operands, and operands come from memory. If your kernel does very little arithmetic per byte it loads, the compute units sit idle waiting on the memory system, and the only ceiling that matters is bandwidth.
The bridge between the two is one number:
arithmetic intensity I = FLOPs performed / bytes moved (FLOP/byte)
Low intensity means memory-bound. High intensity means compute-bound. The whole model is just plotting both ceilings against intensity on one chart.
Attainable performance is the smaller of the two limits:
P(I) = min( peak_compute , peak_bandwidth * I )
peak_bandwidth * I term is a diagonal line on a log-log plot (slope 1):
the bandwidth-bound regime. Double the intensity, double the achievable
FLOP/s, because you are getting more work out of every byte.peak_compute term is a flat horizontal line: the compute-bound regime.
Past a certain intensity, more arithmetic per byte buys you nothing because
the ALUs are already saturated.They cross at the ridge point:
I_ridge = peak_compute / peak_bandwidth (FLOP/byte)
That ridge is the most important number on the chart. Any kernel to the left of it is memory-bound; the fix is to move fewer bytes (fusion, better data types, caching, blocking). Any kernel to the right is compute-bound; the fix is to do the arithmetic more efficiently (better instructions, tensor cores, vectorize).
Modern accelerators have pushed the ridge far to the right. An A100 doing FP16 matmul has roughly 312 TFLOP/s over 1.55 TB/s, a ridge near 200 FLOP/byte. That is why so much of ML systems work is really just a fight to raise arithmetic intensity above the ridge.
Drag the orange kernel point. Move it left/right to change arithmetic intensity, up/down to change achieved performance. Pick a hardware preset or set the ceilings by hand. The readout tells you which regime you are in and how much of the attainable ceiling you are actually using.
A few kernels and roughly where they land, to calibrate intuition. Intensity here assumes you actually move data through DRAM and counts useful FLOPs.
| Kernel | Arithmetic intensity | Typical verdict |
|---|---|---|
Vector add c = a + b (FP32) |
~0.08 FLOP/byte | Deeply memory-bound everywhere |
| SpMV (sparse matrix-vector) | ~0.2 FLOP/byte | Memory-bound, the classic HPC headache |
| 3D stencil / Jacobi sweep | ~0.5 FLOP/byte | Memory-bound until heavily blocked |
| BLAS-2 GEMV | ~2 FLOP/byte | Memory-bound on accelerators |
| Large dense GEMM (FP16) | ~100+ FLOP/byte | Compute-bound, the one kernel that hits peak |
| Flash-attention (fused) | ~tens FLOP/byte | Fusion is what pushes it rightward |
The pattern is the same in both the HPC and the ML worlds: the cheap, elementwise, or sparse operations live on the diagonal and are bandwidth limited, and the only way to climb the roofline is to raise intensity. That is the entire reason kernel fusion exists. Fusing two memory-bound ops means you load the data once and do twice the arithmetic per byte, sliding the point to the right along the diagonal until, ideally, it tucks under the flat ceiling.
The roofline is a ceiling, not a prediction. It assumes perfect overlap of compute and memory, infinite-depth pipelines, and no latency. Real kernels miss the roof for reasons the basic model does not show: cache effects (the bandwidth ceiling is really a stack of rooflines, one per level of the memory hierarchy), instruction mix that cannot reach peak FLOP/s, occupancy and launch overhead, and synchronization. The hierarchical and “cache-aware” roofline variants add those ceilings back as extra diagonals. For a first pass, though, one diagonal and one flat line tell you the most important thing: which direction to push.
peak_compute / peak_bandwidth, is the number that decides your fate.