6.1.2 · D4 · HinglishParallelism & Multicore

ExercisesInstruction-level vs thread-level parallelism

2,604 words12 min read↑ Read in English

6.1.2 · D4 · Hardware › Parallelism & Multicore › Instruction-level vs thread-level parallelism

Ye exercises ek ladder climb karti hain. L1 Recognition (kya tum ise naam de sakte ho?) → L2 Application (kya tum formula mein plug in kar sakte ho?) → L3 Analysis (kya tum explain kar sakte ho kyun ek number aata hai?) → L4 Synthesis (kya tum ideas combine kar sakte ho?) → L5 Mastery (kya tum ek choice design aur defend kar sakte ho?).

Har problem ka ek full worked solution ek collapsible callout ke andar chhupa hua hai — use cover karo, khud try karo, phir reveal karo. Ye page tumhara self-test hai parent topic ke liye.

Shuru karne se pehle, ek shared toolbox. Hum Amdahl's Law ko baar baar use karenge, toh aao ensure karein ki har symbol samajh aaya ho.

Ek tasveer kyun serial part villain hai:


Level 1 — Recognition

Recall Solution 1.1

(a) ILP — bahut saare independent instructions, ek stream. Ye superscalar idea hai. (b) TLP — bahut saare independent streams (tabs), alag cores. (c) DLPek instruction, bahut saara data. Dekho SIMD-Vector-Processing. Ye ILP NAHI hai (sirf ek instruction!) aur TLP bhi NAHI hai (sirf ek thread!). (d) TLP — do threads ek core share karte hain. Ek core ke andar execution units share karna fir bhi thread-level hai, kyunki streams independent programs hain.

Recall Solution 1.2

Jhooth. Issue width ek ILP knob hai — ye ek thread ko uske apne independent instructions per cycle mein zyada execute karke faster khatam hone deta hai. Threads ki sankhya ek TLP knob hai (cores / hardware contexts). Ye orthogonal dials hain: tum ek badhao doosra fixed reh sakta hai.


Level 2 — Application

Recall Solution 2.1

Plug in karo: serial fraction , parallel part . Dhyan do ki serial 0.2 already pura parallel part ke barabar hai — isliye hum ke kareeb bhi nahi pohanchte.

Recall Solution 2.2

(a) . (b) . Aath guna zyada cores (8 → 64) se sirf ~2.6× zyada speedup mila. Serial 0.05 hume choke kar raha hai.

Recall Solution 2.3

ILP aur TLP yahan independent multiplicative factors hain (har thread individually ILP win enjoy karta hai): (parent ke se match karta hai).


Level 3 — Analysis

Recall Solution 3.1

(a) . ✓ (b) Serial dependency chain (pointer chasing — tum next load nahi kar sakte jab tak current load return nahi karta) pin karta hai; woh 0.9 term denominator dominate karta hai chahe machine kitni bhi wide ho. : . 4→16 wide jaane se hum 1.081 se 1.103 tak gaye — ek rounding error. Isliye Memory-Level-Parallelism aur pointer-chasing latency aisi code mein dominate karti hain.

Recall Solution 3.2

Design A (pure ILP): .

Design B (TLP × per-thread ILP): Per-thread ILP: . TLP across 4 cores: . Combined: .

Design B jeet jaata hai ( vs ) kyunki deep ILP diminishing returns hit karta hai (woh ceiling), jabki cores mein kaam spread karna abundant algorithmic parallelism exploit karta hai. Ye industry ka multicore ki taraf swing hai — dekho Power-Performance-Tradeoffs.


Level 4 — Synthesis

Recall Solution 4.1

Har ek ke liye: , , total .

Total

Best: . Kyunki (threads mein zyada parallel fraction hai instructions se zyada), optimum zyada cores ki taraf lean karta hai — lekin poori tarah tak nahi, kyunki thodi ILP width abhi bhi pay karti hai. Sweet spot interior mein hai.

Recall Solution 4.2

Pehle ceiling: jab , , toh . Acha — ceiling se neeche hai, toh ye reachable hai.

Solve karo . Toh cores (integer tak round up karna padega). Check: ✓; (short).


Level 5 — Mastery

Recall Solution 5.1

, .

Total

(a) jeetataa hai (). ILP yahan almost useless hai ( ceiling ), toh wide cores wasted silicon hain. Thread count hi ek lever hai jisme headroom hai.

(b) Haan, SMT plausibly teeno se behtar hai. Bottleneck latency hai, throughput nahi: har thread ek memory load return hone ka wait karta hua stall karta hai (pointer chasing). SMT ek core ko allow karta hai ki jab thread T1 ek load miss par stalled ho, tab thread T2 ki ready instructions execute kare — otherwise-dead cycles fill karke. Ye memory latency ko useful work mein convert karta hai bina algorithm ko zyada parallel kiye. Ye exactly us weakness (load-to-use stalls) par directly attack karta hai jo ILP aur naive multicore dono hide karne mein fail karte hain. Ye Memory-Level-Parallelism hai jo threading ke through harvest hota hai.

Recall Solution 5.2

, set karo: . .

Toh 99.78% kaam parallel hona chahiye; sirf 0.22% serial ho sakta hai. Plain words mein: code almost perfectly dividable hona chahiye jisme essentially koi setup, synchronization, ya final-merge step na ho. Real reason fail hota hai: synchronization aur shared-data overhead (locks, 128 cores ke beech cache-coherence traffic, thread spawn/join) easily 0.22% se zyada kha jaata hai, effective serial fraction badhata hai aur speedup claim se kaafi neeche aa jaata hai.