5.2.9 · D4 · HinglishProcessor Datapath & Pipelining

ExercisesPipeline throughput and CPI

3,995 words18 min read↑ Read in English

5.2.9 · D4 · Hardware › Processor Datapath & Pipelining › Pipeline throughput and CPI

Yeh page ek ladder hai. Har rung pichle se harder hai. Problem ko pehle khud try karo, uske baad solution kholo — collapsible callout answer tab tak hide karta hai jab tak tum click nahi karte. Yahan sab kuch Pipeline throughput and CPI pe based hai; agar koi symbol unfamiliar lage, toh parent note ne usse define kiya hai, aur yeh page usse use karta hai.

Shuru karne se pehle, un chaar symbols ko dobara anchor karte hain jinpe hum sabse zyada rely karenge, taaki koi bhi symbol bina wajah use na ho.

Toh master clock-period rule jo hum baar baar invoke karenge woh hai:

Figure 1 (niche) is poore page ka mental model hai. Pehle uska legend padho:

Figure — Pipeline throughput and CPI

Level 1 — Recognition

Goal: ek definition padho aur ek number plug in karo.

Recall Solution L1.1

KYA karna hai: slowest stage dhundho, phir register overhead add karo. KYUN: har stage usi same edge pe clock karta hai, isliye tick itni lambi honi chahiye ki worst stage finish ho sake aur uska output register latch ho sake.

Recall Solution L1.2

KYA: throughput . KYUN: ke saath, har tick mein ek instruction exit karti hai, aur ek tick seconds ka hota hai.

Recall Solution L1.3

KYA: CPI = total cycles instructions. KYUN: CPI ek per-instruction average hai, isliye hum poore bill ko count se divide karte hain.


Level 2 — Application

Goal: do ya teen formulas ko chain karo.

Recall Solution L2.1

KYA: speedup = (time per instruction, single) (time per instruction, pipe). KYUN: ideal CPI steady state mein dono ke liye hai, isliye per-instruction comparison mein ratio sirf clock periods ka ratio hai. nahi — kyunki EX ek bottleneck hai (unbalanced stages) aur hum har tick pay karte hain.

Recall Solution L2.2

KYA: har stall source ka expected cost ideal CPI of 1 pe add karo. KYUN: expected stalls = (fraction of instructions affected) (penalty each). Independent sources add hote hain.

Recall Solution L2.3

KYA: throughput = clock rate / CPI. KYUN: clock rate ticks per second hai; cycles-per-instruction se divide karne par ticks finished instructions mein convert hoti hain.


Level 3 — Analysis

Goal: designs compare karo, reason karo "kaun better hai aur kyun."

Figure 2 dikhata hai ki "split the bottleneck" move clock ke saath exactly kya karta hai: lamba EX bar aadha ho jaata hai, aur ceiling (dashed red line = clock period) gir jaati hai jahan tak agle sabse uncha bar pahunchta hai.

Figure — Pipeline throughput and CPI
Recall Solution L3.1

(a) Naya clock period. KYA: EX ab do 55-ps stages ho gaya hai, toh dobara run karo. KYUN: clock hamesha ek sabse bure stage se set hoti hai; jab EX (110) chala jaata hai, toh naya worst stage MEM hai 100 ps pe (Figure 2 mein nayi red ceiling dekho). Purana ps tha. (b) Naya CPI. KYA: deeper pipe jo extra stall introduce karti hai usse purane CPI 1.20 pe add karo. KYUN: CPI ; purane 0.20 data-hazard stalls rehte hain, aur lambi forwarding distance 0.05 aur badhati hai, isliye stall term 0.20 se badh ke 0.25 ho jaata hai. (c) Throughput ratio. KYA: dono throughputs ka ratio banao, har ek hai. KYUN sirf CPI se compare nahi karte: time per instruction hai — dono factors yahaan badle (CPI badha, gira), isliye sirf CPI se judge karna galat taur pe kaheha ki naya design worse hai. Sirf product hi real speed capture karta hai. Verdict: ek namoonaai 4% gain. KYUN itna kam? EX split karne se bottleneck sirf MEM pe shift hua — clock barely giri (130→120), aur extra stall ne us fayade ka kuch hissa kha liya. Yeh pipelines ko deeper karne ka law of diminishing returns hai. Compare karo 5.3.02-Superscalar-architecture se, jo ki jagah CPI pe attack karta hai.

Recall Solution L3.2

Forwarding se pehle: Forwarding ke baad: sirf load-use subset stall karta hai, 1 cycle pe. Improvement: cycles/instr saved. Dekho 5.2.07-Forwarding-and-bypassing un bypass wires ke liye jo 0-cycle path ko physical banate hain, aur 5.2.03-Data-hazards yeh jaanne ke liye ki load-use ko fully forward kyun nahi kiya ja sakta (data MEM tak ready nahi hota).


Level 4 — Synthesis

Goal: kaafi saari moving parts combine karo aur ek target ki taraf design karo.

Recall Solution L4.1

(a) Max CPI. KYA: throughput = clock/CPI ko invert karo taaki CPI = clock/throughput solve ho sake. KYUN: throughput is baat se set hota hai ki har second mein kitne finished instructions milte hain; target aur clock fix karne ke baad sirf CPI unknown rehta hai. Yeh kisi bhi stall ke saath impossible hai — ek ideal pipeline already CPI 1 pe baith jaati hai aur yeh hazards use usse upar push karte hain. Toh jaise stated hai target sirf prediction se meet nahi ho sakta; dekho hum kitne close hain aur kya chahiye. (b) Mispredict rate solve karo. KYA: CPI ko likho, required 1.00 ke barabar set karo, aur solve karo. KYUN: sirf adjustable hai; equation ko target pe force karna exactly woh batata hai jo target demand karta hai. Ek negative mispredict rate impossible hai. Conclusion: akela 0.60 data-stall term hi CPI force kar deta hai, toh is clock pe 3 Ginstr/s unreachable hai. Design ko data stalls pe attack karna chahiye (forwarding) — branches pe nahi. Full forwarding ke saath dobara karo (data stalls → 0): yaani tab bhi tumhe perfect prediction chahiye. Practically clock raise karna padega. Exactly yahi dead-end designers ko 5.3.02-Superscalar-architecture ki taraf push karta hai (CPI below 1).

Recall Solution L4.2

KYA: har choice ke liye, us stall term ko current CPI se minus karo, phir throughputs compare karo. KYUN: ek stall category eliminate karna CPI sum se exactly uska contribution remove karta hai; clock fixed hone par throughput hai, toh throughput ratio simply hai. Option A — branch stalls khatam karo: naya CPI . Option B — data stalls khatam karo: naya CPI . Current se throughput ratio (clock fixed) : Data stalls khatam karo (Option B): throughput gain ke mukable. KYUN: bada stall term (0.30) bada lever hai — jo dominate karta hai usse speed up karo. Yeh Amdahl's Law disguise mein hai.


Level 5 — Mastery

Goal: limits ke baare mein reason karo, degenerate cases, aur jahan simple model toot jaata hai.

Problems se pehle, hum fill-and-drain picture explicit karte hain, kyunki har Level-5 answer isi pe lean karta hai.

Figure 3 yeh literally dikhata hai: har column mein red exit-boxes ki count 0 se start hoti hai (pipe filling), 1 pe rise karti hai (full), aur busy boxes ki count wapas taper ho jaati hai jab last instructions drain hoti hain.

Figure — Pipeline throughput and CPI
Recall Solution L5.1

(a) Exact CPI. KYA: total cycles ko instruction count se divide karo. KYUN: CPI by definition total-cycles-per-instruction hai; hum sirf approximating ki jagah exact fill-and-drain count carry karte hain. Term fill-and-drain tax hai: "wasted" edge cycles, sab instructions pe amortise ki gayi. Bada pipe (large ) ya short program (small ) → bada tax. (b) ke liye values (toh ). (c) 1 ke 5% ke andar. KYA: tax term demand karo aur solve karo. KYUN: "5% ke andar" matlab CPI hai, yaani extra 0.05 se zyada nahi hona chahiye. (d) Do edge cases, physically.

  • (single instruction, ): pipe kabhi fill nahi hoti. Woh ek instruction sab 5 stages se akele chalti hai; baaki 4 stages har cycle idle baithte hain. CPI — tumhe zero pipelining benefit milta hai, exactly wahi jaisa single-cycle machine ki latency hai. Yeh degenerate "short program" limit hai: pipe depth se chota program har instruction ke liye almost full latency pay karta hai.
  • : pipe bahut mushkil se fill hoti hai, bilkul last instruction ke enter karne par, phir immediately drain shuru ho jaata hai. CPI — phir bhi ideal se 80% upar, kyunki half run filling/draining mein guzar jaata hai. Sirf jab ho tabhi steady-state "har tick mein ek exit" dominate karta hai aur CPI 1 ki taraf settle hota hai.
Recall Solution L5.2

Pehle, woh symbol jo humhe chahiye — IPC. IPC (Instructions Per Cycle) woh average number of instructions hai jo har clock tick mein finish hoti hain — yeh CPI ka plain reciprocal hai: , aur equivalently . Jahaan CPI "ticks per instruction" count karta hai, IPC "instructions per tick" count karta hai. Ek scalar pipeline IPC pe top out karta hai; ek superscalar isse exceed kar sakta hai. (a) Yahaan sustained IPC directly 2.8 diya gaya hai (instructions finished per tick). Toh (b) (Equivalently .) (c) Ek scalar pipeline har tick mein at most ek instruction finish karta hai (CPI ). Ek superscalar har tick mein kaafi saari finish karta hai, isliye CPI 1 se neeche ja sakta hai — dekho 5.3.02-Superscalar-architecture.

Recall Solution L5.3

(a) Clock period. KYA: apply karo. KYUN: zero-delay stage mein 0 contribute karta hai, isliye woh clock ke liye invisible hai — tick 100-ps stages se set hoti hai. (b) Do designs compare karo. KYA: stage remove karne ke baad time-per-instruction () ke dono factors check karo. KYUN: stage remove karna ya CPI dono badal sakta hai; yahaan worst stage unchanged hai isliye 115 ps pe rehta hai, jabki CPI 0.02 se girta hai (ek kam register jo forward karna padta hai). Kyunki identical hai aur CPI gira, time per instruction se (ps) pe aa jaata hai. 4-stage version strictly faster hai. Lesson: jo stage na raise kare na kisi aur stage ko shorten kare woh pure overhead hai — use delete karo.

Recall Self-check clozes

Pipeline clock period equals == of stage delays , sum nahi. Actual CPI equals stalls per instruction ek scalar pipeline ke liye. Throughput equals clock rate CPI. CPI below 1 ke liye superscalar (multiple-issue)== execution chahiye. Total cycles to run instructions in a -stage pipe ::: . Fill-and-drain tax per instruction for instructions in a -stage pipe ::: extra cycles. Ek -stage pipe pe instruction wale program ka CPI ::: exactly (koi overlap nahi, pipe kabhi fill nahi hoti).