6.2.10 · D3GPU Architecture

Worked examples — Occupancy and latency hiding

3,096 words14 min readBack to topic

This page is one thing only: practice. We take the ideas from the parent note and grind them through every kind of situation the topic can hand you — every resource limit, every degenerate input, every "trick" twist an exam loves. Before we start, one promise: nothing here uses a symbol you have not met. If you need a refresher on where warps come from, that lives in 6.2.1-SM-Architecture and 6.2.8-Warp-Scheduling.

Throughout, our reference chip is the A100, whose per-SM budgets are:

Before we touch a single example, here is how to compute each of the three resource-limited warp counts. Every example just plugs numbers into these three definitions.


The scenario matrix

Occupancy problems all reduce to: "which resource runs out first?" Here is every case-class that can decide the answer. Each row is a cell; the examples that follow are tagged with the cell they cover.

Cell What runs out (or the twist) Degenerate/limit angle Covered by
A Registers are the bottleneck very high regs/thread Ex 1, Ex 6
B Shared memory is the bottleneck block granularity waste Ex 2
C Block-count cap is the bottleneck tiny blocks, hit Ex 3
D Nothing limits → 100% possible the "free" case Ex 4
E Zero / degenerate input 0 shared mem, 1 thread/block Ex 4, Ex 5
F Two limits tie pick the min, both equal Ex 6
G Real-world word problem latency-hiding decision Ex 7
H Exam twist: high occupancy ≠ faster spills vs. occupancy Ex 8

The workflow is always the same, so learn it once (chart nodes are labelled P1–P5 so they never clash with the Cell letters above):

Start: read regs, smem, threads per block

Compute W regs

Compute W smem

Compute W blocks

Take the minimum with W max

Divide by W max = Occupancy


Example 1 — Cell A: registers bite first


Example 2 — Cell B: shared memory bites first


Example 3 — Cell C: the block-count cap bites


Example 4 — Cells D & E: the "free" case and the zero input


Example 5 — Cell E extreme: one thread per block


Example 6 — Cell A + F: a register limit that ties

The register–occupancy relationship is worth a picture. Figure s01 plots occupancy against registers/thread on the A100, with our worked example points marked:

Figure — Occupancy and latency hiding

Look at the stepped pink line: occupancy jumps down only when a new warp can no longer fit — it's a staircase, not a smooth slope, because of the floor function. The yellow dots mark Examples 1 (64 regs → 50%), 4 (16 regs → 100%), and 6 (128 regs → 25%).


Example 7 — Cell G: the real-world latency-hiding decision


Example 8 — Cell H: the exam twist (higher occupancy, slower kernel)


Recall

Recall Which resource decides occupancy?

The scarcest one — occupancy . ::: The minimum, because a warp needs every resource simultaneously.

Recall Why must block sizes be multiples of 32?

A block always costs whole warps; extra lanes in a partial warp are masked and wasted (Example 5). ::: 1 thread/block gives 50% warp occupancy but ~1.56% useful work.

Recall Does 100% occupancy always mean fastest?

No — Examples 7 and 8: past "enough to hide latency," extra warps give diminishing returns and can trigger register spills that slow you down. ::: Occupancy is a means to hide latency, not the goal itself.


Related: parent topic · 6.2.1-SM-Architecture · 6.2.8-Warp-Scheduling · 6.2.9-Memory-Coalescing · 6.2.11-Tensor-Cores · 7.1.3-Roofline-Model · 5.3.4-Littles-Law