Exercises — GPU vs CPU design philosophy
6.2.1 · D4· Hardware › GPU Architecture › GPU vs CPU Design Philosophy
Ye problems धीरे-धीरे vocabulary पहचानने से लेकर पूरे design decisions synthesise करने तक चढ़ते हैं। Har solution ek collapsible callout ke andar chhupa hua hai taaki pehle tum khud try kar sako। Arithmetic paper par karo, phir reveal karo। Parent note: GPU vs CPU design philosophy।
Shuru karne se pehle, ek reminder un do words ke baare mein jinpar sab kuch depend karta hai:
Figure 1 (neeche) is poore page ke liye tumhara compass hai: left half hai CPU ki ek fast lane (choti latency), right half hai GPU ki slower lanes ka stack (huge throughput)। Har exercise asal mein yeh pooch raha hai "kya main amber lane par hoon ya cyan lanes par?" — jab bhi confused feel ho, ise dekhte rehna।

Figure 1. Latency vs throughput। Amber box = ek fast CPU worker jo ek single task jaldi finish karta hai। Cyan boxes = bahut saare slower GPU workers jo ek second mein tasks ki puri flood finish karte hain। Note karo ki koi bhi single cyan arrow amber jaisa fast nahi hai — jeet bahut saare arrows hone se aati hai।
Hum parent note se do formulae reuse karenge। Yahan inhe likha gaya hai taaki koi bhi symbol unexplained na rahe।
Level 1 — Recognition
Exercise 1.1 mein ek word use hone se pehle, ek vocabulary piece pehle exist karni chahiye:
Exercise 1.1
Har phrase ke liye batao ki yeh latency-oriented (CPU) ya throughput-oriented (GPU) design se belong karta hai: (a) branch predictor, (b) 8704 simple cores, (c) 64 MB L3 cache, (d) warp scheduler hiding memory stalls, (e) out-of-order execution।
Recall Solution
- (a) branch predictor → CPU (ek thread ko fast move rakhne ke liye speculate karta hai = latency)।
- (b) thousands of simple cores → GPU (bahut saare workers = throughput)।
- (c) huge L3 cache → CPU (ek thread ka data 1 tick door rakhta hai = latency)।
- (d) warp scheduler → GPU (stalled work ko ready work se swap karta hai = throughput high rakhta hai)।
- (e) out-of-order execution → CPU (reorder karta hai ek single thread ka badhane ke liye = latency)। Har answer ko Figure 1 par map karo: (a),(c),(e) single amber lane ko sharpen karte hain; (b),(d) cyan stack ko feed karte hain।
Exercise 1.2
Blank fill karo: GPU par 32 threads ka ek group jo sab ek hi waqt same instruction execute karte hain use ______ kehte hain, aur is execution model ko ______ kehte hain।
Recall Solution
Ek warp; model hai SIMT (Single Instruction, Multiple Threads)। 32 kyun matter karta hai: scheduler ek instruction saare 32 ko ek saath issue karta hai, isliye usse 32 lanes ke liye sirf ek decoder chahiye — yehi exactly hai kaise ek GPU control-logic transistors bachata hai।
Level 2 — Application
Exercise 2.1
Ek CPU instructions ka ek thread aur par run karta hai। compute karo।
Recall Solution
mein plug karo। Denominator: instructions/second। Matlab: 12 billion finished instructions per second par, six billion ko aadha second lagta hai।
Exercise 2.2
Ek image mein pixels hain, har ek ek independent task hai jo leta hai। (a) cores wale CPU par, (b) cores wale GPU par (simplicity ke liye same assume karo) batch time compute karo।
Recall Solution
use karo, s ke saath।
(a) CPU: tasks per core।
(b) GPU: tasks per core।
Padhna: sirf ek cheez badli hai — । Zyada workers → wohi kaam ki pile thinner split hoti hai → chhota batch time। Yahi poori throughput story ek division mein hai — exactly Figure 1 mein cyan stack amber lane ka kaam kai baar kar raha hai।
Exercise 2.3
Parent note ki simplifying assumption use karte hue ki ek batch ki speedup core-count ratio ke barabar hai, , ke liye GPU ki CPU par speedup nikalo।
Recall Solution
Yeh tabhi hold karta hai jab ho taaki dono machines poori tarah busy rahein।
Exercise 2.4 — Edge case: cores se kam tasks
Ek GPU mein cores hain। Tum sirf independent tasks ki ek batch launch karte ho, har ek ns। (a) Kitne cores actually kaam karte hain? (b) Batch time kya hai? (c) Ek single core use karne ke muqable tumhe kya speedup mila, aur yeh 4096× se itna kam kyun hai?
Recall Solution
(a) Ek task per core, isliye sirf 512 of the 4096 cores chalte hain; baaki 3584 idle baithe hain। (b) । Yahan hai, jo upar round hota hai 1 wave of work (tum pass ka fraction nahi run kar sakte), isliye (c) Ek core ke comparison mein jo saare 512 tasks karta hai ( ns), speedup hai — 4096× nahi। Ceiling kyun hai, nahi: tumhe kabhi bhi utna parallel speedup nahi mil sakta jitne tumhare paas independent pieces of work hain। Jab ho, effective speedup par cap ho jaati hai, aur cores wasted silicon hain। Yeh throughput machine ka worst regime hai — Figure 1 mein ek giant cyan stack jisme zyada lanes empty hain। GPU ko bahut kam kaam dena sabse common tarika hai "GPU is slower!" ka surprise paane ka।
Level 3 — Analysis
Exercise se pehle, hum GPU formula ko quote karne ki jagah earn karte hain। Batch model se shuru karo aur ek real GPU ke liye har piece ko refine karo।
Exercise 3.1
Ek GPU kernel ek chip par launch hota hai jisme , , occupancy , aur hai। Har task cycles cost karta hai। compute karo। Phir batao ki agar occupancy (half) ho jaaye toh ka kya hoga।
Recall Solution
Effective working cores: workers। Task-slot rate (denominator): cycles/second। Units check: । ✓ Occupancy half karne se denominator half ho jaata hai, isliye double ho jaata hai tak। Occupancy hidden villain kyun hai: GPU memory latency chhupata hai bahut saare warps rakh ke jo swap in ke liye ready hain। Low occupancy = bahut kam ready warps = cores DRAM wait karte hue idle baithe hain। Arithmetic units exist karte hain lekin unhe koi feed nahi karta।
Exercise 3.2
use karte hue explain karo ki ek CPU designer jo clock aur aage nahi badha sakta, woh branch prediction aur out-of-order execution par transistors kyun kharach karega।
Recall Solution
mein exactly teen knobs hain। program se fixed hai। kuch GHz ke aas-paas ek power/heat wall se takra gaya। Sirf ek remaining knob hai — instructions finished per tick। Branch prediction pipeline ko unknown branches par stall hone se rokti hai, aur out-of-order execution independent instructions dhoondta hai run karne ke liye jab dusre wait kar rahe hoon। Dono badhate hain, jo ghatata hai bina clock ko touch kiye। Isliye exactly woh transistors worth it hain।
Level 4 — Synthesis
Exercise 4.1 — Amdahl's ceiling
Ek program 95% parallelisable hai () aur 5% strictly sequential hai। Amdahl's law use karte hue jahan processors ki sankhya hai aur speedup, GPU cores ke saath speedup compute karo। Phir theoretical maximum speedup compute karo jab ho।
Recall Solution
Sequential fraction । ke saath: Jab , term : Punchline: 4096 cores tumhe dete hain, aur infinite cores sirf dete hain। Chhota sa 5% serial part sab kuch cap kar deta hai। Isliye ek GPU ka raw core count raw speedup mein translate nahi hota jab tak workload almost embarrassingly parallel na ho।
Exercise 4.2 — Crossover point
Maan lo ek task mein independent sub-tasks hain। CPU: cores har ek ns par। GPU: cores har ek ns par (slower cores), plus ek fixed launch overhead of । Sabse chota nikalo jiske liye GPU, CPU ko beat karta hai।
Recall Solution
CPU time: । GPU time: । set karo aur ke liye solve karo: Isliye GPU sub-tasks ke liye jeetta hai। Yahi crossover Figure 2 mein mark hai। Crossover kyun exist karta hai: GPU ek fixed launch tax pay karta hai aur slower cores use karta hai। Tabhi jab kaam ka pile itna bada ho jaata hai, uska 4096-way parallelism woh tax wapas kama leta hai। Chhote jobs CPU par hone chahiye — yeh "do numbers add karne ke liye kernel launch mat karo" ka quantitative version hai।
Figure 2 dono times ko ke against plot karta hai। Ise ek race ki tarah padhna: amber CPU line origin se start hoti hai (koi launch tax nahi) aur steeply chadhti hai; cyan GPU line upar se start hoti hai ( tax) lekin almost flat chadhti hai। Jahan woh cross karte hain woh 4.2 ka answer hai — uske left mein CPU jeetta hai, right mein GPU।

Figure 2. CPU (amber) aur GPU (cyan) batch time ka problem size ke against crossover। par white dot exactly woh break-even point hai jo Exercise 4.2 mein solve kiya gaya। GPU ka flat slope notice karo — yeh throughput hai; CPU ka steep slope dikhata hai ki limited latency scale par kaisi dikhti hai।
Level 5 — Mastery
Exercise 5.1 — Apna budget design karo
Tumhare paas transistor budget hai। Ek simple GPU-style core transistors cost karta hai; ek complex CPU-style core transistors cost karta hai। (a) Agar tum poora budget cores par kharach karo toh har type ke kitne cores build kar sakte ho? (b) Ek latency-bound task sirf 1 core use karta hai lekin usse simple core se 4× zyada per-core performance chahiye; ek throughput-bound task mein independent sub-tasks hain। Har task ke liye, kaun si chip pehle finish karti hai? Numbers ke saath justify karo।
Recall Solution
(a) All-simple: cores। All-complex: cores। Ratio hai, exactly jaisa parent note predict karta hai ()।
(b) Latency task 1 core use karta hai। Complex core woh 4× single-core performance deliver karta hai; simple core nahi kar sakta (yeh ek plain in-order lane hai)। Isliye 1200-complex-core chip yahan jeetti hai — 12,000 simple cores mein se 11,999 idle baithte, ek single dependent chain ke liye useless।
Throughput task mein independent sub-tasks hain। Kam per-core speed par bhi, 12,000-core chip kaam ko zyada finely split karta hai: tasks/core vs tasks/core। Maan lo simple core per task up to slower bhi hai toh bhi jeetta hai, kyunki । Many-simple-core chip jeetti hai।
Mastery point: same silicon budget do opposite machines produce karta hai, aur sahi choice entirely is baat se decide hoti hai ki tumhara kaam ek dependent chain hai ya ek million independent pieces। Yahi GPU-vs-CPU philosophy hai, ek budgeting problem mein reduce karke — Figure 1 ke do halves।
Exercise 5.2 — Choice ek ek sentence mein explain karo
Mechanism ko goal se match karo, phir batao ki alternative kyun galat hota us chip par: (a) GPU hardware threading use karta hai bade caches ki jagah। (b) CPU speculative execution use karta hai zyada cores ki jagah।
Recall Solution
(a) 1000s of cores ke saath, ek private cache per core transistor budget blow kar deta, isliye GPU iske badle bahut saare resident warps rakhta hai aur ek stalled warp ko ek ready wale se swap karta hai — DRAM latency memory se nahi balki parallelism se chhupata hai। Bada cache galat buy hota: yeh ek thread ki latency optimise karta, jo ek throughput machine ko parwah nahi। Dekho GPU memory hierarchy। (b) Ek CPU ka kaam ek fast dependent thread hai, isliye extra cores jo woh use nahi kar sakta wasted silicon hain; speculation instead us single thread ka badhata hai। Zyada cores galat buy hote un code ke liye jo parallelise nahi ho sakta — yaad karo von Neumann sequential fetch-decode-execute chain, aur kaise SIMD vs SIMT width ko alag tarike se handle karta hai।
Recall Self-test recap
GPU, CPU ko tabhi beat karta hai jab ::: kaam highly parallel ho, launch overhead pay karne ke liye itna bada ho, aur serial fraction chota ho। Clock wall ke baad CPU ka sirf ek bacha hua knob hai ::: IPC (instructions per cycle), branch prediction aur out-of-order execution se badhaya jaata hai। Occupancy mein enter karta hai ::: denominator mein effective core count par multiplier ki tarah (latency-hiding capacity)। Jab N_tasks, P se kam ho, speedup cap hoti hai ::: N_tasks par (cores se kam tasks hone par idle cores hoti hain)। Serial fraction wale program ke liye Amdahl's ceiling hai ::: , processor count se independent।