6.2.7 · D3GPU Architecture

Worked examples — Memory hierarchy (global, shared, registers)

3,310 words15 min readBack to topic

This page is a drill. We take the three storage levels from the parent note — registers, shared memory, global memory — and hit every kind of arithmetic question they can throw at you. Before we start, one promise: no symbol appears here without a plain-word meaning. Let us fix the vocabulary once.


The scenario matrix

Every memory question is one of these cells. The examples below are labelled with the cell they cover.

Cell What makes it different Example
A. Register limit register budget is the bottleneck Ex 1
B. Register tie / zero slack division comes out exact, no waste Ex 2
C. Register vs thread-cap a different limit wins Ex 3
D. Shared-memory limit scratchpad is the bottleneck, not registers Ex 4
E. Bank conflict — worst case all threads hit one bank (serialize ×32) Ex 5
F. Bank conflict — the padding fix change a number, conflict vanishes Ex 6
G. Coalescing — best case one memory transaction Ex 7
H. Coalescing — strided / worst case 32 transactions, degenerate access Ex 7
I. Word problem real speedup from tiling Ex 8
J. Exam twist / limiting value which resource caps occupancy? push a knob to its extreme Ex 9

We will always compute occupancy: the fraction of the SM's maximum threads that are actually busy.

Why care? An idle SM cannot hide the long wait for global memory. Higher occupancy means more threads ready to run while others wait. (See Memory Latency Hiding.)

Figure — Memory hierarchy (global, shared, registers)

The bar chart above is the mental picture for every register/shared example: one SM has one register pile and one scratchpad. Every block you launch takes a bite out of both. When either bite would overflow, no more blocks fit.


Cell A — Register limit is the bottleneck


Cell B — Exact division, zero slack


Cell C — A different limit wins (thread cap)


Cell D — Shared memory is the bottleneck


Cell E — Bank conflict, the worst case

The figure below draws exactly this idea: the row of 32 boxes across the top are the 32 bank-doors, the orange arrows show the worst case of Ex 5 (all arrows crashing into one door), and the teal arrows show the fixed case of Ex 6 (one arrow per door). Keep it in view while reading both examples.

Figure — Memory hierarchy (global, shared, registers)

Cell F — The one-number padding fix


Cells G & H — Coalescing, best and worst

The figure below is the picture for the two cases below it: the teal band on top is the coalesced case (one crate covers the whole warp), and the orange scattered boxes below are the strided case (each thread strands in its own crate). Refer to it as you read Ex 7.

Figure — Memory hierarchy (global, shared, registers)

Cell I — The real-world word problem


Cell J — The exam twist / limiting value


Recall Self-test — cover the answers

Ex 1 occupancy ::: 75% (register-limited to 3 blocks) Ex 2 occupancy ::: 100% (exact division, 8 blocks, 2048 threads) Ex 3 winning limit ::: the thread cap (min of 16 and 8 blocks = 8) Ex 4 occupancy ::: 25% (shared memory limits to 2 blocks) Ex 5 serialization factor ::: 32 (all threads hit bank 0) Ex 6 serialization factor after 33-padding ::: 1 (each thread own bank) Ex 7 coalesced vs strided transaction ratio ::: 32× Ex 8 tiling speedup ::: 16× fewer global reads Ex 9 registers/thread for 100% occupancy ::: 32