Worked examples — Pipeline throughput and CPI
5.2.9 · D3· Hardware › Processor Datapath & Pipelining › Pipeline throughput and CPI
Yeh page parent topic ka drill ground hai. Kuch bhi compute karne se pehle, aao har tarah ke questions list karein jo yeh topic throw kar sakta hai. Phir hum ek example per cell solve karte hain, taaki koi bhi scenario aapko naya na lage jab tak woh already dekha hua na ho.
The scenario matrix
Pipeline performance ke baare mein har exam question in cells mein se ek mein aata hai. Hamara kaam hai inhe sab cover karna.
| # | Cell (case class) | Kya tricky banata hai | Hit by |
|---|---|---|---|
| A | Ideal fill-up — instructions ke liye exact cycles | "" fill cost, chhota | Ex 1 |
| B | Limiting value | CPI par kyun collapse hota hai | Ex 1 |
| C | Clock period unbalanced stages se | max lo, register overhead add karo | Ex 2 |
| D | Speedup vs single-cycle | sum-of-stages ÷ pipe period | Ex 2 |
| E | CPI with data + control hazards | do stall sources combine karo | Ex 3 |
| F | Forwarding stalls hatata hai | before/after CPI difference | Ex 4 |
| G | Branch prediction improvement | accuracy → mispredict rate flip | Ex 5 |
| H | Degenerate: 1-stage / perfectly balanced | edge jahan pipelining kuch nahi karta | Ex 6 |
| I | Zero-hazard vs all-hazard extremes | CPI floor aur ek worst case | Ex 6 |
| J | Superscalar: CPI < 1 | IPC > 1, real-world word problem | Ex 7 |
| K | Exam twist: kaun sa processor faster hai? | GHz akela ek trap hai | Ex 8 |
Prerequisite links agar kisi cell ko backup chahiye: 5.2.03-Data-hazards, 5.2.05-Control-hazards, 5.2.07-Forwarding-and-bypassing, 5.3.02-Superscalar-architecture, 5.1.05-CPU-performancemetrics.
Example 1 — Cells A & B: exact cycles aur limit
Forecast: abhi andaza lagao — kya CPI girega ya badhega jaise badhta hai? Kis number ki taraf?

Figure dekho: har row ek instruction hai jo har cycle mein ek stage right slide karti hai. Staircase sirf pehli instruction ke WB corner tak pahunchne mein cycles leta hai; uske baad, har single cycle mein ek finish hoti hai.
Step 1 — Fill count karo. Pehli instruction ko saare cycles chahiye IF→ID→EX→MEM→WB travel karne ke liye. Yeh step kyun? Pipe ke full hone se pehle kuch bhi finish nahi ho sakta — yeh unavoidable start-up cost hai.
Step 2 — Steady state count karo. Pehle ke finish hone ke baad, baaki instructions ek per cycle finish hoti hain. Kyun? Baad ki har instruction ek cycle peeche hai usse jo aage hai — assembly-line rhythm.
Step 3 — CPI nikalne ke liye divide karo.
| Total cycles | CPI | |
|---|---|---|
| 1 | 5 | 5.000 |
| 5 | 9 | 1.800 |
| 100 | 104 | 1.040 |
| 1000004 | 1.000004 |
Step 4 — The limit. Jaise , constant ke saath negligible ho jaata hai: Yahan limit kyun? CPI ek per-instruction average hai; fixed fill cost zyada se zyada instructions mein share hoti jaati hai, isliye uska per-instruction hissa vanish ho jaata hai.
Verify: ke liye: ✓. Single instruction CPI deta hai (latency ke barabar — pipelining ek instruction ke liye kuch nahi deta, bilkul expected hai).
Example 2 — Cells C & D: clock period aur speedup
Forecast: kaun sa stage clock set karta hai, aur kya speedup ideal tak pahunchega?

Step 1 — Sabse slow stage chuno. Saare stages ek hi clock edge par tick karte hain, isliye clock sirf utni hi fast ho sakti hai jitni slowest stage allow karti hai. Max kyun, average nahi? Ek slow worker poori line rok deta hai chahe baaqi fast hon.
Step 2 — Register overhead add karo. Kyun? Har stage ka result next edge se pehle pipeline register mein latched hona chahiye.
Step 3 — Single-cycle period = saare stages ka sum. Bina overlap ke ek instruction ek lambe cycle mein har stage se guzarti hai:
Step 4 — Speedup. se neeche kyun? Stage imbalance (EX clock ko hog karta hai) aur ps overhead ideal chura lete hain.
Verify: ✓. Ideal (balanced, no overhead) hota — hamara correctly usse neeche hai.
Example 3 — Cell E: dono hazard types ke saath CPI
Forecast: kya CPI ke kareeb hoga ya ke?
Step 1 — Branch stalls per instruction. Sirf mispredicted branches cycles waste karte hain: Triple product kyun? Jo branches hain unka fraction × jo mispredict hoti hain unka fraction × har ek kitne cycles waste karta hai.
Step 2 — Data-hazard stalls per instruction.
Step 3 — Ideal floor 1 mein add karo.
Step 4 — Throughput. CPI se divide kyun? Har instruction ab cycles khaati hai, isliye har second mein kam finish hoti hain.
Verify: ✓ (raw cycle rate par wapas). Ideal throughput hota ; hame uska milta hai.
Example 4 — Cell F: forwarding stalls mitaa deta hai
Forecast: forwarding kitna CPI wapas kharid leta hai?
Step 1 — CPI without forwarding.
Step 2 — CPI with forwarding. Stalls ho jaate hain: Zero kyun? EX result seedha next EX input ko diya jaata hai, isliye koi writeback ka wait nahi karta.
Step 3 — Cycles saved per instruction.
Verify: speedup — forwarding yahan poora hazard penalty recover kar leta hai, parent note ke claim se exactly match karta hai. ✓
Example 5 — Cell G: behtar branch prediction
Forecast: accurate jaane se kitne CPI points bachte hain?
Step 1 — Accuracy ko mispredict rate mein convert karo. Mispredict : toh aur . Flip kyun? Penalties un branches se aate hain jinhe hum galat predict karte hain, sahi se nahi.
Step 2 — CPI at 50% accuracy.
Step 3 — CPI at 90% accuracy.
Step 4 — Improvement.
Verify: throughput ratio → ek throughput gain. ✓
Example 6 — Cells H & I: degenerate aur extreme inputs
Forecast: (a) ke liye, koi speedup hai bhi kya?
Step 1 — (a) . Total cycles , toh CPI hai lekin koi overlap nahi — yeh hai hi single-cycle machine. Degenerate result kyun? Ek stage ke saath pipeline karne ke liye kuch nahi hai; single-cycle pe speedup .
Step 2 — (b) balanced, no overhead. Exactly kyun? Perfect balance aur zero overhead ideal limit hai — speedup stage count tak pahunchta hai.
Step 3 — (c) zero-hazard floor. CPI scalar pipeline ke liye se neeche kabhi nahi ja sakta (ek finish per cycle max) — yeh sirf Example 7 mein badalta hai.
Step 4 — (d) all-hazard worst case. kyun? "Har" instruction hazard karti hai → hazard rate . Yeh -cycle-stall wali duniya ka ceiling hai.
Verify: (a) speedup agar us single stage ne same ps sum kiya — pipelining mein kuch change na ho toh kuch nahi badlta ✓. (b) ✓. (d) ✓.
Example 7 — Cell J: superscalar, CPI 1 se neeche (real-world)
Forecast: kya ek single instruction sach mein cycle ka quarter le sakti hai?
Step 1 — IPC, CPI ka reciprocal hai. Reciprocal kyun? CPI cycles-per-instruction hai; use flip karo instructions-per-cycle paane ke liye.
Step 2 — Throughput.
Step 3 — CPI < 1 kyun? Koi single instruction faster nahi hai — core sirf ek hi cycle mein 4–6 instructions issue karta hai multiple execution units use karke. Average karne par, har instruction ek cycle share karti hai, isliye per-instruction cycle count se neeche aa jaata hai.
Verify: IPC ✓; aur CPI ✓.
Example 8 — Cell K: exam trap "kaun sa faster hai?"
Forecast: flashy GHz chip — winner ya bait?
Step 1 — Performance clock rate ÷ CPI. CPI se divide kyun? Raw GHz sirf cycles count karta hai; cycles-per-instruction se divide karke hi yeh kaam hone mein badalta hai.
Step 2 — Compare karo. deliver karta hai ke ke mukable — Q faster hai.
Step 3 — Kitna zyada.
Verify: P par instructions ka time s; Q par s. Ratio ✓ — "slower-clocked" chip se jeetta hai. Yeh iron law ek punch mein hai.
Recall Self-test
Ideal k-stage pipe mein bahut saari instructions ke limit mein CPI ::: 1 Pipeline clock period formula ::: Superscalar CPI < 1 kyun de sakta hai ::: woh ek cycle mein multiple instructions issue karta hai (IPC > 1) Faster kaun: 5 GHz CPI=4 ya 3 GHz CPI=1 ::: 3 GHz wala (performance = rate ÷ CPI) Forwarding se cycles saved per instruction jab 30% hazard, 2-cycle stall ::: 0.60