6.2.10 · D3 · HinglishGPU Architecture

Worked examplesOccupancy and latency hiding

3,333 words15 min read↑ Read in English

6.2.10 · D3 · Hardware › GPU Architecture › Occupancy and latency hiding

Yeh page sirf ek kaam ke liye hai: practice. Hum parent note ke ideas lete hain aur unhe har tarah ki situation mein grind karte hain jo yeh topic de sakta hai — har resource limit, har degenerate input, har "trick" twist jo exam pasand karta hai. Shuru karne se pehle, ek promise: yahan koi bhi symbol use nahi hoga jo aapne pehle nahi dekha. Agar aapko warps ke baare mein refresher chahiye, woh 6.2.1-SM-Architecture aur 6.2.8-Warp-Scheduling mein milega.

Poore note mein, hamara reference chip A100 hai, jiske per-SM budgets hain:

Koi bhi example touch karne se pehle, yahan bataya gaya hai ki har ek resource-limited warp count kaise compute karte hain. Har example sirf inhi teen definitions mein numbers plug karta hai.


Scenario matrix

Occupancy problems sab reduce hote hain: "kaun sa resource pehle khatam hota hai?" Yahan har case-class hai jo answer decide kar sakti hai. Har row ek cell hai; aane wale examples tagged hain us cell ke saath jo woh cover karte hain.

Cell Kya khatam hota hai (ya twist) Degenerate/limit angle Covered by
A Registers bottleneck hain bahut high regs/thread Ex 1, Ex 6
B Shared memory bottleneck hai block granularity waste Ex 2
C Block-count cap bottleneck hai tiny blocks, hit Ex 3
D Kuch bhi limit nahi → 100% possible "free" case Ex 4
E Zero / degenerate input 0 shared mem, 1 thread/block Ex 4, Ex 5
F Do limits tie karte hain min lo, dono equal Ex 6
G Real-world word problem latency-hiding decision Ex 7
H Exam twist: high occupancy ≠ faster spills vs. occupancy Ex 8

Workflow hamesha same rehta hai, toh ise ek baar seekho (chart nodes P1–P5 label hain taaki woh upar ke Cell letters se kabhi clash na karein):

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 pehle bite karte hain


Example 2 — Cell B: shared memory pehle bite karta hai


Example 3 — Cell C: block-count cap bite karta hai


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


Example 5 — Cell E extreme: ek thread per block


Example 6 — Cell A + F: ek register limit jo tie karta hai

Register–occupancy relationship ek picture ki deserve karti hai. Figure s01 A100 par registers/thread ke against occupancy plot karta hai, hamare worked example points marked hain:

Figure — Occupancy and latency hiding

Stepped pink line dekho: occupancy tabhi neeche jump karta hai jab ek naya warp fit nahi ho sakta — yeh staircase hai, smooth slope nahi, floor function ki wajah se. Yellow dots mark karte hain Examples 1 (64 regs → 50%), 4 (16 regs → 100%), aur 6 (128 regs → 25%).


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


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


Recall

Recall Occupancy kaun sa resource decide karta hai?

Sabse scarcest wala — occupancy . ::: Minimum, kyunki ek warp ko har resource simultaneously chahiye hoti hai.

Recall Block sizes 32 ke multiples kyun hone chahiye?

Ek block hamesha whole warps cost karta hai; ek partial warp mein extra lanes masked aur wasted hoti hain (Example 5). ::: 1 thread/block 50% warp occupancy deta hai lekin ~1.56% useful work.

Recall Kya 100% occupancy hamesha fastest hota hai?

Nahi — Examples 7 aur 8: "enough to hide latency" ke baad, extra warps diminishing returns dete hain aur register spills trigger kar sakte hain jo aapko slow karte hain. ::: Occupancy ek means hai latency hide karne ka, khud goal nahi.


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