5.2.9 · D4Processor Datapath & Pipelining

Exercises — Pipeline throughput and CPI

3,655 words17 min readBack to topic

This page is a ladder. Each rung is harder than the last. Do a problem before opening its solution — the collapsible callout hides the answer until you click it. Everything here builds on Pipeline throughput and CPI; if a symbol feels unfamiliar, that parent note defined it, and this page uses it.

Before we start, let us re-anchor the four symbols we will lean on the hardest, so nothing is used unearned.

So the master clock-period rule we will invoke again and again is:

Figure 1 (below) is the mental model for the whole page. Read its legend first:

Figure — Pipeline throughput and CPI

Level 1 — Recognition

Goal: read a definition and plug one number in.

Recall Solution L1.1

WHAT we do: find the slowest stage, then add register overhead. WHY: every stage clocks on the same edge, so the tick must be long enough for the worst stage to finish and for its output register to latch.

Recall Solution L1.2

WHAT: throughput . WHY: with , one instruction exits every tick, and a tick lasts seconds.

Recall Solution L1.3

WHAT: CPI = total cycles instructions. WHY: CPI is a per-instruction average, so we divide the whole bill by the count.


Level 2 — Application

Goal: chain two or three formulas together.

Recall Solution L2.1

WHAT: speedup = (time per instruction, single) (time per instruction, pipe). WHY: ideal CPI is for both the per-instruction comparison at steady state, so the ratio is just the ratio of clock periods. Not — because EX is a bottleneck (unbalanced stages) and we pay every tick.

Recall Solution L2.2

WHAT: add each stall source's expected cost onto the ideal CPI of 1. WHY: expected stalls = (fraction of instructions affected) (penalty each). Independent sources add.

Recall Solution L2.3

WHAT: throughput = clock rate / CPI. WHY: clock rate is ticks per second; dividing by cycles-per-instruction converts ticks into finished instructions.


Level 3 — Analysis

Goal: compare designs, reason about "which is better and why."

Figure 2 shows exactly what the "split the bottleneck" move does to the clock: the tall EX bar is sawn in half, and the ceiling (dashed red line = the clock period) drops to whatever the next tallest bar reaches.

Figure — Pipeline throughput and CPI
Recall Solution L3.1

(a) New clock period. WHAT: re-run with EX now two 55-ps stages. WHY: the clock is always set by the single worst stage; once EX (110) is gone, the new worst stage is MEM at 100 ps (look at the new red ceiling in Figure 2). Old ps. (b) New CPI. WHAT: add the extra stall the deeper pipe introduces onto the old CPI of 1.20. WHY: CPI ; the old 0.20 data-hazard stalls remain, and the longer forwarding distance adds 0.05 more, so the stall term grows from 0.20 to 0.25. (c) Throughput ratio. WHAT: form the ratio of the two throughputs, each . WHY compare and not CPI alone: the time per instruction is — both factors changed here (CPI rose, fell), so judging by CPI alone would falsely say the new design is worse. Only the product captures real speed. Verdict: a measly 4% gain. WHY so small? Splitting EX only moved the bottleneck to MEM — the clock barely dropped (130→120), and the extra stall ate part of that. This is the law of diminishing returns from deepening pipelines. Contrast with 5.3.02-Superscalar-architecture, which attacks CPI itself rather than .

Recall Solution L3.2

Before forwarding: After forwarding: only the load-use subset stalls, at 1 cycle. Improvement: cycles/instr saved. See 5.2.07-Forwarding-and-bypassing for the bypass wires that make the 0-cycle path physical, and 5.2.03-Data-hazards for why load-use can't be fully forwarded (the data isn't ready until MEM).


Level 4 — Synthesis

Goal: combine several moving parts and design toward a target.

Recall Solution L4.1

(a) Max CPI. WHAT: invert throughput = clock/CPI to solve CPI = clock/throughput. WHY: throughput is set by how many finished instructions each second's worth of ticks yields; pinning the target and the clock leaves CPI as the only unknown. That is impossible with any stalls — an ideal pipeline already sits at CPI 1 and these hazards push above it. So the target as stated cannot be met by prediction alone; let's see how close and what's needed. (b) Solve for mispredict rate . WHAT: write CPI as , set it equal to the required 1.00, and solve for . WHY: only is adjustable; forcing the equation to the target tells us exactly what the target demands. A negative mispredict rate is impossible. Conclusion: the 0.60 data-stall term alone already forces CPI , so 3 Ginstr/s is unreachable at this clock. The design must attack data stalls (forwarding) — not branches. Re-doing with full forwarding (data stalls → 0): i.e. even then you need perfect prediction. Realistically the clock must rise. This is exactly the kind of dead-end that pushes designers toward 5.3.02-Superscalar-architecture (CPI below 1).

Recall Solution L4.2

WHAT: for each choice, subtract that stall term from the current CPI, then compare throughputs. WHY: eliminating a stall category removes exactly its contribution from the CPI sum; with the clock fixed, throughput , so the throughput ratio is simply . Option A — kill branch stalls: new CPI . Option B — kill data stalls: new CPI . Throughput ratio vs current (clock fixed) : Kill data stalls (Option B): a throughput gain vs . WHY: the bigger stall term (0.30) is the bigger lever — you speed up what dominates. That is Amdahl's Law in disguise.


Level 5 — Mastery

Goal: reason about limits, degenerate cases, and where the simple model breaks.

Before the problems, we make the fill-and-drain picture explicit, because every Level-5 answer leans on it.

Figure 3 shows this literally: the number of red exit-boxes per column starts at 0 (pipe filling), rises to 1 (full), and the count of busy boxes tapers back down as the last instructions drain out.

Figure — Pipeline throughput and CPI
Recall Solution L5.1

(a) Exact CPI. WHAT: divide total cycles by the instruction count. WHY: CPI is by definition total-cycles-per-instruction; we just carry the exact fill-and-drain count instead of approximating. The term is the fill-and-drain tax: the "wasted" edge cycles, amortised over all instructions. Big pipe (large ) or short program (small ) → big tax. (b) Values for (so ). (c) Within 5% of 1. WHAT: demand the tax term and solve for . WHY: "within 5%" means CPI , i.e. the extra must not exceed . (d) The two edge cases, physically.

  • (single instruction, ): the pipe never fills. That one instruction walks through all 5 stages alone; the other 4 stages sit idle every cycle. CPI — you get zero pipelining benefit, exactly the same as a single-cycle machine's latency. This is the degenerate "short program" limit: a program shorter than the pipe depth pays close to full latency per instruction.
  • : the pipe just barely fills on the very last instruction's entry, then immediately begins to drain. CPI — still 80% above ideal, because half the run is spent filling/draining. Only when does the steady-state "one exit per tick" dominate and CPI settle toward 1.
Recall Solution L5.2

First, the symbol we need — IPC. IPC (Instructions Per Cycle) is the average number of instructions that finish per clock tick — it is the plain reciprocal of CPI: , and equivalently . Where CPI counts "ticks per instruction," IPC counts "instructions per tick." A scalar pipeline tops out at IPC ; a superscalar can exceed it. (a) Here the sustained IPC is given directly as 2.8 (instructions finished per tick). So (b) (Equivalently .) (c) A scalar pipeline finishes at most one instruction per tick (CPI ). A superscalar finishes several per tick, so CPI can drop below 1 — see 5.3.02-Superscalar-architecture.

Recall Solution L5.3

(a) Clock period. WHAT: apply . WHY: the zero-delay stage contributes 0 to the , so it is invisible to the clock — the tick is set by the 100-ps stages. (b) Compare the two designs. WHAT: check both factors of time-per-instruction () after removing the stage. WHY: removing a stage could change either or CPI; here the worst stage is unchanged so stays 115 ps, while CPI falls by 0.02 (one fewer register to forward across). Since is identical and CPI dropped, time per instruction falls from to (ps). The 4-stage version is strictly faster. Lesson: a stage that neither raises the nor shortens some other stage is pure overhead — delete it.

Recall Self-check clozes

The pipeline clock period equals == of stage delays , not the sum. Actual CPI equals stalls per instruction for a scalar pipeline. Throughput equals clock rate CPI. CPI below 1 requires superscalar (multiple-issue)== execution. Total cycles to run instructions in a -stage pipe ::: . Fill-and-drain tax per instruction for instructions in a -stage pipe ::: extra cycles. A program with instruction on a -stage pipe has CPI ::: exactly (no overlap, pipe never fills).