6.2.7 · D3 · HinglishGPU Architecture

Worked examplesMemory hierarchy (global, shared, registers)

3,503 words16 min read↑ Read in English

6.2.7 · D3 · Hardware › GPU Architecture › Memory hierarchy (global, shared, registers)

Yeh page ek drill hai. Hum parent note ke teen storage levels — registers, shared memory, global memory — lete hain aur har tarah ke arithmetic questions attack karte hain jo exams mein aa sakte hain. Shuru karne se pehle, ek promise: yahan koi bhi symbol bina plain-word meaning ke nahi aayega. Vocabulary ek baar fix kar lete hain.


Scenario matrix

Har memory question in cells mein se ek hai. Neeche ke examples mein cell label lagaa hai.

Cell Kya ise different banata hai Example
A. Register limit register budget bottleneck hai Ex 1
B. Register tie / zero slack division exact nikli, koi waste nahi Ex 2
C. Register vs thread-cap ek alag limit jeet jaati hai Ex 3
D. Shared-memory limit scratchpad bottleneck hai, registers nahi Ex 4
E. Bank conflict — worst case sab threads ek bank pe (serialize ×32) Ex 5
F. Bank conflict — padding fix ek number badlo, conflict khatam Ex 6
G. Coalescing — best case ek memory transaction Ex 7
H. Coalescing — strided / worst case 32 transactions, degenerate access Ex 7
I. Word problem tiling se real speedup Ex 8
J. Exam twist / limiting value kaunsa resource occupancy cap karta hai? knob ko extreme pe push karo Ex 9

Hum hamesha occupancy compute karenge: SM ke maximum threads ka woh fraction jo actually busy hai.

Kyun care karein? Ek idle SM global memory ke lambe wait ko hide nahi kar sakta. Zyada occupancy matlab zyada threads ready hain run karne ke liye jab doosre wait kar rahe hain. (Dekho Memory Latency Hiding.)

Figure — Memory hierarchy (global, shared, registers)

Upar ka bar chart har register/shared example ke liye mental picture hai: ek SM ke paas ek register pile aur ek scratchpad hota hai. Aap jo bhi block launch karte ho woh dono se ek bite leta hai. Jab kisi bhi bite se overflow ho jaye, aur blocks fit nahi honge.


Cell A — Register limit bottleneck hai


Cell B — Exact division, zero slack


Cell C — Ek alag limit jeet jaati hai (thread cap)


Cell D — Shared memory bottleneck hai


Cell E — Bank conflict, worst case

Neeche ki figure bilkul yahi idea draw karti hai: upar 32 boxes ki row 32 bank-doors hain, orange arrows Ex 5 ka worst case dikhate hain (sab arrows ek door pe crash karte hue), aur teal arrows Ex 6 ka fixed case dikhate hain (ek arrow per door). Dono examples padhte waqt ise dekhte raho.

Figure — Memory hierarchy (global, shared, registers)

Cell F — Ek number ka padding fix


Cells G & H — Coalescing, best aur worst

Neeche ki figure neeche ke dono cases ki picture hai: upar ka teal band coalesced case hai (ek crate poore warp ko cover karta hai), aur neeche ke orange scattered boxes strided case hain (har thread apne crate mein alag hai). Ex 7 padhte waqt ise refer karo.

Figure — Memory hierarchy (global, shared, registers)

Cell I — Real-world word problem


Cell J — Exam twist / limiting value


Recall Self-test — answers cover karo

Ex 1 occupancy ::: 75% (register-limited to 3 blocks) Ex 2 occupancy ::: 100% (exact division, 8 blocks, 2048 threads) Ex 3 winning limit ::: thread cap (min of 16 and 8 blocks = 8) Ex 4 occupancy ::: 25% (shared memory limits to 2 blocks) Ex 5 serialization factor ::: 32 (sab threads bank 0 hit karte hain) Ex 6 serialization factor after 33-padding ::: 1 (har thread apna 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