6.2.3 · D3GPU Architecture

Worked examples — CUDA cores and execution model

3,747 words17 min readBack to topic

This is the "get your hands dirty" child of the parent topic. The parent gave you the machinery; here we run every kind of input through it — best case, worst case, zero, degenerate, a real word problem, and an exam trap. Nothing new is assumed: every symbol used below is re-anchored the moment it appears.



The scenario matrix

Every cell below is a distinct case class this topic can throw at you. The worked examples are labelled with the cell they hit. (Every symbol in this table — , , SM — was defined in the block just above.)

# Case class The extreme / corner it tests Example
A Perfect launch threads divide evenly into warps, all cores fed Ex 1
B Ragged tail N not a multiple of block size → a partial final warp Ex 2
C Degenerate: N ≤ 0 or N tiny fewer threads than one warp; idle cores; negative/zero Ex 3
D Memory best case coalesced access, efficiency Ex 4
E Memory worst case strided access, efficiency minimal Ex 4
F Branch divergence warp splits into two paths, serialized Ex 5
G Latency hiding — succeeds enough warps to cover the stall Ex 6
H Latency hiding — fails (limit) required warps exceed the SM cap Ex 6
I Real-world word problem image processing, choose a launch config Ex 7
J Exam twist "128 cores ÷ 32 = ¼ cycle" trap + register ceiling Ex 8

Prerequisites if any row feels shaky: 6.1.03-SIMD-vs-SIMT, 6.2.02-GPU-memory-hierarchy, and later 6.2.04-occupancy-and-performance.


Ex 1 — Cell A: the perfect launch

This is the "textbook happy path" — everything divides. Every later example is a deliberate break from this.


Ex 2 — Cell B: the ragged tail


Ex 3 — Cell C: degenerate & tiny inputs (N ≤ 0 and N tiny)


Ex 4 — Cells D & E: memory best case vs worst case

Figure — CUDA cores and execution model

Ex 5 — Cell F: branch divergence

Figure — CUDA cores and execution model

Ex 6 — Cells G & H: latency hiding, success and failure


Ex 7 — Cell I: real-world word problem


Ex 8 — Cell J: the exam twist (two traps in one)


Recall — one line per cell

Recall Why does the ragged tail still cost a full warp?

Because a warp is atomic — 32 lanes are issued together; idle lanes are masked, not skipped. ::: A warp is always issued as 32 lanes; the guard if (i<N) masks the extra ones but they still occupy the warp slot.

Recall What happens for N = 0 or negative N?

Both collapse to "do nothing": blocks and the i < N guard is never true. ::: Zero or negative N launches 0 blocks and every guard comparison fails, so no thread does work — no crash.

Recall Case E: efficiency of stride-32 access?

— 32 transactions of 128 bytes each for only 128 useful bytes. ::: .

Recall A two-way branch split: cost and utilisation?

Costs add ( cycles), utilisation drops to 50% because half the lanes idle at all times. ::: Paths serialize, so cycles add and utilisation halves for an even split.

Recall Latency hiding formula and when it fails?

; it fails when this exceeds the ~64-warp SM cap. ::: When > resident-warp cap, latency is exposed; raise to lower the requirement.

Recall Register ceiling: 40 registers/thread on a 65,536-register SM?

Full occupancy allows only 32/thread, so you drop to resident threads. ::: More registers per thread forces fewer resident threads (), lowering occupancy.

Recall The "quarter cycle" trap?

False — a warp instruction is cycle; 128 cores give 4 warps/cycle of throughput, not sub-cycle latency. ::: One warp instruction is atomic at 1 cycle minimum; extra cores add throughput, not lower latency.

See also 7.3.01-parallel-programming-patterns and 9.1.02-neural-network-training-on-GPUs where these exact corners decide real performance.