6.2.10 · D4 · HinglishGPU Architecture

ExercisesOccupancy and latency hiding

2,963 words13 min read↑ Read in English

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

Shuru karne se pehle, ek reminder us ek formula ka jis par sab kuch tika hai. Agar aapne pehle kabhi nahi dekha, toh ise dhyaan se padho:

Barrel-limit idea ki picture dekho:

Figure — Occupancy and latency hiding

Level 1 — Recognition

Recall Solution

KYA: Occupancy active aur maximum warps ka ratio hai. KYUN: Yahi literally iska definition hai — yahan koi resource limits dhundhne ki zaroorat nahi, hume active-warp count seedha diya gaya hai. Jawab: .

Recall Solution

Step 1 — warps per block. Ek warp threads ka hota hai, toh warps per block. KYUN 32 se divide karein: hardware hamesha threads ko ki fixed lanes mein group karta hai; yahi scheduling ki sabse chhoti unit hai. Step 2 — total active warps. warps. Step 3 — occupancy. . Jawab: warps/block, occupancy.


Level 2 — Application

Recall Solution

Step 1 — registers per warp. Har warp mein threads hain, toh yeh registers consume karta hai. KYUN 32 se multiply karein: lanes mein se har ek ko har register ki apni private copy chahiye; ek warp ki cost per-thread cost times hai. Step 2 — kitne aise warps fit honge. KYUN floor : aap fractional warp host nahi kar sakte — jo leftover registers ek poore warp ko cover nahi kar sakte woh simply waste ho jaate hain. Step 3 — occupancy. Koi aur limit nahi, . Jawab: warps, .

Recall Solution

Hume har resource check karna hoga aur minimum lena hoga. Register limit: Shared-memory limit: KB mein kitne KB blocks fit honge? Block-count limit: blocks -block max se kaafi kam hai, toh yeh binding nahi hai. Step — minimum lo: . Jawab: shared memory bottleneck hai; .

Recall Solution

KYUN yeh tool: Little's Law exactly yahi answer deta hai "ek latency aur rate diya gaya ho toh pipe full rakhne ke liye kitna in flight hona chahiye". Yahi bilkul hamara sawaal hai — hum latency kam nahi kar rahe, hum use overlap kar rahe hain. Jawab: (single-scheduler idealisation). Parent note explain karta hai kyun real SMs ko sirf warps chahiye: schedulers plus instruction-level parallelism SM-wide concurrency supply karte hain.


Level 3 — Analysis

Recall Solution

(a) warps . (b) warps . (c) KYUN 128 phir bhi jeet sakta hai: agar kernel memory-bound hai, toh warps shayad load latency hide karne ke liye kaafi hain (yaad karo SM-wide warps usually sufficient hain). Saath hi data registers mein rakhne se spills local memory mein avoid hote hain jo har baar hundreds of cycles cost karte hain. Toh bina spills ke spills ke saath ko beat kar sakta hai. Jawab: (a) ; (b) ; (c) memory-bound kernels jahan extra registers spilling prevent karte hain.

Recall Solution

KYUN loads-per-warp se divide karein: har warp ab outstanding requests contribute karta hai, toh woh -cycle gap fill karne mein ka kaam karta hai. KYUN real number kaafi kam hai: A100 mein schedulers hain jo consecutive cycles mein alag-alag warps se issue karte hain, aur memory system bahut saare requests parallel mein service karta hai (memory-level parallelism). Idealised figure ko effective SM-wide issue width se divide karo aur aap empirical warp range mein pahunch jaoge. Jawab: idealised; practice mein warps kyunki schedulers + MLP.

Recall Solution

KYA har ek ko limit karta hai: A ki ceiling registers hai; B ki ceiling shared memory. Binding constraint hi ek aise hai jise relax karna worth hai (barrel plank logic). Kernel A: register use kam karna badhata hai, seedha minimum lift karta hai → occupancy badhti hai. Kernel B: zyada registers kuch nahi karte — shared memory abhi bhi sabse chhota plank hai; aap non-binding limit raise karoge. Jawab: Kernel A fayda uthata hai. B ke liye aapko shared-memory usage kam karni hogi (e.g. chhote tiles).


Level 4 — Synthesis

Recall Solution

(a) Har limit check karo.

  • Registers: warps.
  • Shared mem: blocks warps.
  • Blocks: blocks max, toh blocks warps dete hain (extra-binding nahi).
  • . Binding constraint: shared memory (20 warps). (b) Change: shared memory ko KB/block tak aadha karo. Tab blocks warps smem ke liye; registers abhi bhi allow karte hain; block max allow karta hai. Naya minimum . KYUN 25 pe ruk jaata hai, 40 pe nahi: jab shared memory binding nahi rehti, registers naya sabse chhota plank ban jaate hain warps pe. Synthesis lesson: ek bottleneck fix karna agla expose karta hai. Jawab: (a) , shared-memory bound. (b) KB smem → , ab register bound.
Recall Solution

KYUN roofline: yeh batata hai ek kernel apni intensity se kya ceiling reach kar sakta hai — ridge ke upar compute-bound, neeche memory-bound. Step — ridge-point intensity (jahan dono ceilings milti hain): Hamara , toh hum ridge ke kaafi neeche hain → memory-bound. (b) Implication: performance data feed karne se set hoti hai, aur moderate occupancy (, yani warps) already load latency hide kar leta hai. tak push karna diminishing returns deta hai; better hai coalescing improve karna taaki har transaction useful bytes move kare. Jawab: (a) memory-bound (); (b) ~50% occupancy kaafi hai — occupancy ki jagah coalescing fix karo.


Level 5 — Mastery

Recall Solution

(a) Occupancy.

  • P: warps .
  • S: warps . (b) Kaun jeetta hai. Version S occupancy double karta hai — tempting lagta hai. Lekin yeh cycles ki serial spill latency har thread ke critical path pe add karta hai, jabki P cycles bachata hai data resident rakh ke. Kyunki kernel memory-bound hai, P ke warps () already SM-wide genuine load latency hide karne ke liye enough concurrency supply karte hain. S mein extra warps kuch naya hide nahi karte lekin spill tax pay karte hain. Decision: Version P faster hai. S mein occupancy badhi, lekin per-thread critical-path latency explode ho gayi — aur jab latency already hidden ho, zyada warps help nahi karte. Jawab: (a) P , S ; (b) P jeetta hai — spills serial cycles add karte hain jo koi bhi occupancy yahan recover nahi kar sakti.
Recall Solution

Warp scheduling view: ek scheduler har cycle mein ek ready warp pick karta hai. Ek stalled warp (apne load ka wait kar raha hai) ready nahi hota, toh agar wahi ek warp hai, scheduler ke paas issue karne ke liye kuch nahi → SM idle ho jaata hai. SM architecture view: bahut saare warps ka context (registers) on-chip simultaneously rehta hai, switch free banata hai — lekin sirf tab jab doosre warps switch karne ke liye exist karein. Ek warp = kuch nahi switch karne ke liye. Little's Law view: in-flight requests needed . Akela warp ek load issue karta hai phir wait karna padta hai; woh apne aap cycles ke worth independent requests outstanding nahi rakh sakta, kyunki uske baad ke instructions us load ke result pe depend karte hain. Rule of thumb: aapko multiple independent warps chahiye — empirically modern SMs pe — taaki schedulers ko fed rakha ja sake aur memory system busy rahe jab koi bhi warp wait kar raha ho. Jawab: latency hiding inherently ek between-warps mechanism hai; ILP ek warp ke andar dependencies se bounded hai, toh warps practical minimum hai.


Recall Quick self-test (cloze)

Occupancy active warps divided by maximum warps per SM. Occupancy formula minimum of all resource limits leta hai. Registers per warp charge hote hain per-thread count times 32. Ek akela warp apni load latency hide nahi kar sakta kyunki latency hiding ek between-warps mechanism hai.

A100 (19.5 TFLOP/s, 1555 GB/s) pe ridge-point intensity kya hai?
About FLOP/byte
Warp counts ko floor kyun karte hain?
Aap fractional warp host nahi kar sakte; leftover resource waste ho jaata hai
Ek memory-bound kernel ke liye jo roofline ridge ke neeche hai, kya occupancy chase karna worth hai?
Nahi — already latency hide karta hai; coalescing fix karo