6.2.3 · D3 · HinglishGPU Architecture

Worked examplesCUDA cores and execution model

4,064 words18 min read↑ Read in English

6.2.3 · D3 · Hardware › GPU Architecture › CUDA cores and execution model

Yeh parent topic ka "haath se kaam karo" wala child note hai. Parent ne tumhe machinery di; yahan hum har tarah ka input us machinery se guzaarte hain — best case, worst case, zero, degenerate, ek real word problem, aur ek exam trap. Kuch bhi naya assume nahi kiya gaya: neeche use kiya gaya har symbol wahan pe re-anchor hota hai jahan woh pehli baar aata hai.



Scenario matrix

Neeche har cell ek alag case class hai jo yeh topic tumpe throw kar sakta hai. Worked examples us cell ke saath labeled hain jise woh hit karte hain. (Is table mein har symbol — , , SM — upar wale block mein define kiya gaya tha.)

# Case class Woh extreme / corner jo test hota hai Example
A Perfect launch threads evenly warps mein divide ho jaate hain, sab cores ko kaam milta hai Ex 1
B Ragged tail N block size ka multiple nahi → ek partial final warp Ex 2
C Degenerate: N ≤ 0 ya N bahut chhota ek warp se bhi kam threads; idle cores; negative/zero Ex 3
D Memory best case coalesced access, efficiency Ex 4
E Memory worst case strided access, efficiency minimum Ex 4
F Branch divergence warp do paths mein split ho jaata hai, serialized Ex 5
G Latency hiding — succeeds stall cover karne ke liye kaafi warps hain Ex 6
H Latency hiding — fails (limit) required warps SM cap se zyada ho jaate hain Ex 6
I Real-world word problem image processing, launch config choose karo Ex 7
J Exam twist "128 cores ÷ 32 = ¼ cycle" trap + register ceiling Ex 8

Agar koi bhi row shaky lage to prerequisites: 6.1.03-SIMD-vs-SIMT, 6.2.02-GPU-memory-hierarchy, aur baad mein 6.2.04-occupancy-and-performance.


Ex 1 — Cell A: perfect launch

Yeh "textbook happy path" hai — sab kuch divide ho jaata hai. Har baad wala example is se ek deliberate break hai.


Ex 2 — Cell B: ragged tail


Ex 3 — Cell C: degenerate & tiny inputs (N ≤ 0 aur 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 aur failure


Ex 7 — Cell I: real-world word problem


Ex 8 — Cell J: exam twist (ek mein do traps)


Recall — har cell ke liye ek line

Recall Ragged tail abhi bhi ek poore warp ki cost kyun leta hai?

Kyunki warp atomic hai — 32 lanes ek saath issue hote hain; idle lanes mask hote hain, skip nahi; woh warp slot occupy karte hain. ::: Warp hamesha 32 lanes ke roop mein issue hota hai; guard if (i<N) extra walo ko mask karta hai lekin woh warp slot phir bhi lete hain.

Recall N = 0 ya negative N ke liye kya hota hai?

Dono "kuch mat karo" mein collapse ho jaate hain: blocks aur i < N guard kabhi true nahi hota. ::: Zero ya negative N 0 blocks launch karta hai aur har guard comparison fail ho jaata hai, isliye koi thread kaam nahi karta — koi crash nahi.

Recall Case E: stride-32 access ki efficiency?

— sirf 128 useful bytes ke liye 128 bytes ke 32 transactions. ::: .

Recall Two-way branch split: cost aur utilisation?

Costs add hote hain ( cycles), utilisation 50% tak gir jaati hai kyunki aadhe lanes har waqt idle hain. ::: Paths serialize hote hain, isliye cycles add hote hain aur even split mein utilisation aadhi ho jaati hai.

Recall Latency hiding formula aur kab fail hoti hai?

; yeh fail hoti hai jab yeh ~64-warp SM cap se zyada ho jaaye. ::: Jab > resident-warp cap, latency expose ho jaati hai; requirement kam karne ke liye badhao.

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

Full occupancy sirf 32/thread allow karta hai, isliye tum resident threads tak gir jaate ho. ::: Zyada registers per thread matlab kam resident threads (), occupancy kam ho jaati hai.

Recall "Quarter cycle" trap?

Jhooth — ek warp instruction cycle hai; 128 cores 4 warps/cycle throughput dete hain, sub-cycle latency nahi. ::: Ek warp instruction minimum 1 cycle par atomic hai; extra cores throughput add karte hain, latency kam nahi karte.

Dekho bhi 7.3.01-parallel-programming-patterns aur 9.1.02-neural-network-training-on-GPUs jahan yahi exact corners real performance decide karte hain.