S46 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

S4 · Lesson 6 · Pipelining limits and optimal depth

Latch overhead, hazard penalties that grow with depth, the optimal pipeline and power-aware depth

In the early 2000s one processor family stretched its pipeline past 30 stages to chase clock rate, and its successor went back to about 14. The reason is that a deeper pipeline wins clock rate but loses in two ways. Every stage adds latch overhead that no amount of splitting removes, and every hazard that empties the pipeline (a mispredicted branch, above all) costs more cycles the deeper the pipeline is. Somewhere between too shallow and too deep is an optimum, and once power is counted, the optimum moves shallower still. This lesson finds it.

  • Time per instruction, in FO4 delays, against pipeline depth k: TPI=(tk+o)(1+bk), with t FO4 of logic per instruction, o FO4 of overhead per stage, and b stall cycles per instruction per stage of depth.
  • The marker is the depth that minimizes TPI, k*=t/(ob). The curve is flat near it, so a few stages either way cost little.
  • Dashed: the power-aware metric BIPS³/W (performance cubed over power, with each stage's latches adding power), scaled to its own peak. Its optimum is shallower.

Predict

A core has 100 FO4 of logic per instruction, 4 FO4 of overhead per stage, and loses 0.05 cycles per instruction per stage to hazards. Which depth gives the shortest time per instruction?

Name it

Why a pipeline can't be split forever

  • Overhead per stage: latch delay, setup, clock skew and jitter, together o, about 2 to 5 FO4. The period is t/k+o, never below o.
  • Imbalance: stages can't be cut at arbitrary points; the slowest one sets the clock.
  • Hazards that grow with depth: a branch resolved at the end of a deep front end flushes more instructions, and load-use distances grow in cycles. A simple model charges b stall cycles per instruction per stage, so CPI = 1 + bk.

The optimum

TPI(k)=(tk+o)(1+bk),k*=tob

At the optimum the overhead's share and the hazards' share balance. Studies of real workloads found the performance optimum near 6 to 8 FO4 of logic per stage.

Counting power

Each stage's latches and clocking add power, roughly P(k)=P0(1+pk). Metrics that weigh energy, such as BIPS/W or BIPS³/W (whose ranking doesn't change when voltage scaling trades speed for power), have shallower optima than raw performance.

The FO4 yardstick

Expressing delays in FO4 (S3.18) makes these results independent of the process: a 100 FO4 instruction path in 22 stages runs at about 8.5 FO4 per cycle in any technology.

Worked example

With t = 100 FO4, o = 4 FO4 and b = 0.05, compare 5, 10, 22 and 40 stages.

Show the solution
  1. 5 stages. TPI(5)=(20+4)(1.25)=30FO4
  2. 10 stages. TPI(10)=(10+4)(1.5)=21FO4
  3. 22.4 stages, the optimum. TPI(22.4)=8.472×2.118=17.9FO4
  4. 40 stages. TPI(40)=(2.5+4)(3)=19.5FO4
  5. What the extra depth bought. The last 18 stages beyond the optimum bought a clock 1.3 times faster and lost it all to the CPI.

Answer 30, 21, 17.9 and 19.5 FO4 per instruction for 5, 10, 22 and 40 stages, so about 22 stages is best.

Worked example

A mispredicted branch in a 14-stage pipeline resolves at stage 11. With 20% branches and a 5% misprediction rate, what CPI do mispredictions add? What if a 31-stage pipeline resolves at stage 25?

Show the solution
  1. 14 stages, resolving at stage 11. The penalty is 10 cycles: ΔCPI=0.2×0.05×10=0.10
  2. 31 stages, resolving at stage 25. The penalty is 24 cycles: ΔCPI=0.2×0.05×24=0.24
  3. What the deeper pipeline must overcome. Its faster clock has to outrun 0.14 more CPI from branches alone, before counting longer load-use and cache-hit latencies in cycles.

Answer mispredictions add 0.10 CPI to the 14-stage pipeline and 0.24 CPI to the 31-stage one.

Worked example

An instruction's path is 120 FO4 of logic, each stage adds 3 FO4 of overhead, and hazards cost 0.1 cycles per instruction per stage. What depth is best, and how much logic does each stage hold there?

Show the solution
  1. Best depth. k*=t/(ob)=120/0.3=20stages each with 120/20 = 6 FO4 of logic.
  2. Time per instruction. TPI=(6+3)(1+0.1×20)=27FO4 which also equals (tb+o)2.
  3. Compare with real designs. That 6 FO4 per stage agrees with the 6 to 8 FO4 that studies of real workloads found.

Answer 20 stages is best, each holding 6 FO4 of logic.

Check

A core has 120 FO4 of logic per instruction, 3 FO4 of overhead per stage and loses 0.08 cycles per instruction per stage of depth. What depth minimizes time per instruction?

Check

With 80 FO4 of logic, 3 FO4 of overhead and 0.1 stalls per instruction per stage, what's the time per instruction at 30 stages, in FO4?

Check

A pipeline of 20 stages splits 100 FO4 of logic evenly, with 3 FO4 of overhead per stage. What fraction of each cycle is overhead?

Check

Branches are 0.15 of instructions, 0.03 of them mispredicted, and they resolve at stage 25. How much CPI do mispredictions add?

Check

How many FO4 is each cycle when 100 FO4 of logic is split over 25 stages with 3 FO4 of overhead?

Check

At the optimal depth, what's the time per instruction for t = 100 FO4, o = 3 FO4 and b = 0.08?

Check

An instruction's path is 120 FO4; each stage adds 2 FO4 of overhead, and hazards cost 0.08 cycles per instruction per stage.

(a)

What is the time per instruction with 20 stages?

(b)

What depth minimizes it?

Check

A pipeline's time per instruction is (t/k+o)(1+bk).

Step 1

What depth k minimizes it?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Check

Write best_depth(t, o, b, p=None): search depths k = 1 to 100 and return (best k, its time per instruction (t/k+o)(1+bk)). With p = None, minimize the time; with a number p, maximize BIPS3/W, (1/TPI)3/(1+pk), for power that grows as 1+pk.

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Explain why

Why does counting power push the best pipeline depth shallower than the depth that maximizes performance?

Practice

Keep practicing

10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.