What “faster” means: the Iron Law, Amdahl and pipeline arithmetic

After this lesson you will take an instruction-mix table, a clock frequency and a stall count and say, with numbers, which of two machines is faster, by how much, and where the next cycle is worth taking away.

The 10 June 2025 exam paper puts two CPUs in front of you. They run the same 100 instructions. CPU1 needs 2.7 clock cycles per instruction on average, CPU2 only 2.4 — and yet CPU1 is 2.22 times faster. Its clock is 2.5 times faster, but it is not 2.5 times faster. Why not?

Hennessy and Patterson add a third machine to the puzzle: one that executes 833 million instructions per second and loses, on the same program, to one that executes 400 million.

Three puzzles that look like three different subjects. They are one formula with three factors, and by the end of the lesson you will solve each of them in your head.

Time is the only honest metric

Whether you are buying a machine or designing one, you need a basis for comparison and a metric. The notes name two metrics, and they pull in opposite directions. Execution time (also called latency or response time) is the time needed to complete one task: lower is better. Throughput (bandwidth) is the number of tasks completed per unit of time: higher is better.

The notes' Example 1 (p. 246) is a pair of aircraft. Concorde flies at 1350 mph and crosses from Washington to Paris in 3 hours; a Boeing 747 flies at 610 mph and takes 6.5 hours. On execution time Concorde wins; on throughput, passenger-miles per hour, the 747 wins, because it carries far more people per flight. Optimising one metric can hurt the other. This lesson is about one processor running one program, so execution time is the metric; pipelining, in the last section, is a throughput technique that makes no single instruction finish sooner.

\[ \text{Performance} = \frac{1}{\text{Execution time}} \] \[ \text{Perf}(X) = \Big(1 + \tfrac{n}{100}\Big)\,\text{Perf}(Y) \] \[ \text{Time}(Y) = \Big(1 + \tfrac{n}{100}\Big)\,\text{Time}(X) \]
\(n\)
"X is \(n\%\) faster than Y": defined on the ratio of the two execution times

Performance is the reciprocal of execution time, and "X is \(n\%\) faster than Y" is defined as a ratio: the time of the slower machine is \(1 + n/100\) times the time of the faster one. Example 2 of the notes (p. 247): machine A runs a program in 10 s, machine B in 15 s. Is A 50% faster or 33% faster? Compute the ratio, \(15/10 = 1.5\), so A is 50% faster. The 33% is the time A saves as a fraction of B's time, \((15 - 10)/15\); it is a true number, but it is not what "faster" means in this course or in Hennessy & Patterson. "X is \(k\) times faster than Y" is the same ratio without the percentage: \(k = \text{Time}(Y)/\text{Time}(X)\).

A processor executes synchronously to a clock. The clock cycle time \(T_{CLK}\) is the duration of one cycle, in seconds; the clock frequency \(f_{CLK} = 1/T_{CLK}\) is the number of cycles per second, in hertz. The notes write \(f_{clock}\) on some pages and \(f_{CLK}\) on others; the exam's formula sheet writes \(f_{CLK}\), and so does this lesson.

Performance is the reciprocal of execution time, and "n% faster" is a ratio of times, never a difference.

The Iron Law: three numbers that multiply

Think of typing a letter. The time it takes is the number of words, times the keystrokes each word needs, times the seconds each keystroke takes. Three factors, three different people responsible: the author decides the words, the keyboard layout decides the keystrokes per word, the typist's fingers decide the seconds per keystroke. A typist twice as fast on a layout that needs 2.5 times more keystrokes per word is the slower typist.

A processor is the same product. The CPU time of a program is the number of clock cycles it takes, times the cycle time; and the number of cycles is the number of instructions executed, times the average number of cycles per instruction. (CPU time is the processor's own time on the program; the elapsed, wall-clock time adds I/O and other programs. The notes use the two names as one on p. 248; the exam asks for CPU time.)

\[ \text{CPU time} = \text{Clock cycles} \times T_{CLK} \] \[ \text{CPU time} = IC \times CPI \times T_{CLK} \] \[ \text{CPU time} = \frac{IC \times CPI}{f_{CLK}} \]
\(IC\)
instruction count: the instructions executed (dynamic count, loops included), not the lines of the program
\(CPI\)
clock cycles per instruction, averaged over the whole program
\(T_{CLK}\)
clock cycle time; \(f_{CLK} = 1/T_{CLK}\)
CPU time = IC × CPI × TCLK words keys per word seconds per key IC × CPI × TCLK how many how long each how long a cycle compiler, ISA organisation, ISA technology, depth the three levers
Fig. 1. The Iron Law of processor performance. Each factor is moved by a different design level, and moving one usually moves another: a deeper pipeline shortens the cycle but adds stalls, a richer instruction set shortens the program but makes each instruction take longer.

The levers in the figure are background from Hennessy & Patterson, not from the notes: the compiler and the instruction set decide IC; the organisation (pipeline, caches, how many instructions issue per cycle) and the instruction set decide CPI; the technology and the pipeline depth decide \(T_{CLK}\). Only the product is performance, which is why architects argue in seconds and not in megahertz.

The number that pushed David Patterson towards RISC, as he tells it in the 2018 Turing lecture: the VAX 11/780 averaged a CPI of 10, and 20% of its instruction set took 60% of the microcode but only 0.2% of the execution time. CPI is a design decision, not a constant of nature.

CPI, IPC and the instruction mix

CPI is the average number of clock cycles each instruction takes: total clock cycles divided by \(IC\). Its reciprocal, IPC (instructions per cycle), is the number of instructions that complete per cycle; the two say the same thing, and you will meet IPC again when a machine can finish more than one instruction per cycle.

A real program is a mix of instruction classes with different costs: a load may take 4 cycles where an ALU operation takes 1. The average CPI must weight each class by how often it occurs. Here is where the weighted form comes from.

  1. Count the cycles class by class: \(I_i\) instructions of class \(i\), each taking \(CPI_i\) cycles. The program's total cycles are the sum over the classes (the bracket of the notes' eq. 16):

    \[ \text{Clock cycles} = \sum_{i=1}^{n} CPI_i \, I_i . \]
  2. Divide by the instruction count to get the average cycles per instruction:

    \[ CPI = \frac{\sum_i CPI_i\, I_i}{IC} = \sum_i CPI_i \,\frac{I_i}{IC} . \]
  3. The ratio \(I_i / IC\) is the frequency \(F_i\) of class \(i\): the fraction of the executed instructions that belong to it. The frequencies sum to 1. That gives the formula-sheet form (eq. 19–20):

    \[ CPI = \sum_{i=1}^{n} CPI_i\, F_i , \qquad F_i = \frac{I_i}{IC} . \]
  4. Put it back into the Iron Law and the two routes agree: \(IC \times CPI\) with the weighted CPI is exactly \(\sum_i CPI_i\, I_i\), the class-by-class cycle count, so both give the same CPU time once multiplied by \(T_{CLK}\).

The notes' Example 3 (pp. 249–250) is the first instance: 100 instructions at 500 MHz with this mix.

Notes, Example 3: weighted CPI of a five-class mix. The last column is the product you add up.
Instruction TypeFrequencyCPI\(F_i \times CPI_i\)
ALU43%10.43
Load21%40.84
Store12%40.48
Branch12%20.24
Jump12%20.24
CPI100%2.23

CPI is \(2.23\), and the time is \(100 \times 2.23 \times 2\) ns \(= 446\) ns: 223 cycles of 2 ns each. Nothing was added for a pipeline fill, because this is the general bookkeeping: the cycles per class already include whatever each class costs.

The exam's version: CPU1 against CPU2

Exercise 3 of the 10 June 2025 paper is this same table, twice. CPU1 runs at 500 MHz, CPU2 at 200 MHz; both execute a kernel of 100 instructions with the frequencies and cycle counts below. The paper asks for the average CPI of each CPU, the CPU time of each, and "how much is CPU1 faster than CPU2?". The two right-hand columns are the ones you add on the answer sheet.

10 June 2025, Exercise 3, part 1 — the paper's four columns, plus the two products (recomputed).
Instruction TypeInstruction FrequencyCPU1 Clock CyclesCPU2 Clock Cycles\(F \times CPI_1\)\(F \times CPI_2\)
ALU30%210.600.30
LOAD10%860.800.60
STORE20%230.400.60
JUMP30%220.600.60
BRANCH10%330.300.30
CPI100%2.702.40

\(CPI_1 = 2.7\) and \(CPI_2 = 2.4\): CPU2 has the better CPI. Now the cycle times: 500 MHz is 2 ns, 200 MHz is 5 ns. \(\text{CPUtime}_1 = 100 \times 2.7 \times 2\) ns \(= 540\) ns; \(\text{CPUtime}_2 = 100 \times 2.4 \times 5\) ns \(= 1200\) ns. CPU1 is \(1200/540 = 2.22\) times faster, that is 122% faster in the formula sheet's \(n\%\) form. The first puzzle of the hook is solved: the clock is 2.5 times faster, but the CPI is \(2.7/2.4 = 1.125\) times worse, and \(2.5 / 1.125 = 2.22\). Look at the ALU and LOAD rows to see where the worse CPI comes from: an ALU operation costs 2 cycles instead of 1, a load 8 instead of 6. A faster clock means more, shorter cycles for the same work, and memory does not get faster when the clock does. That trade-off is the whole memory block of this course, from lesson 22 on.

CPU duel: edit the mix, watch the time

The table is the exam's: a frequency per class and the cycles each class costs on each CPU, plus the clock and the instruction count. Every cell can be edited. The bars are the CPU times, split by class in the order of the table rows (alternating dark and light segments); the readouts give CPI, time, MIPS and the verdict.

  1. Before touching anything, predict: on the exam preset, which single change helps CPU1 more — raising its clock from 500 to 600 MHz, or cutting its LOAD cost from 8 cycles to 4? Then try both (reset in between).
    What you should see

    The clock change takes CPU1 from 540 ns to 450 ns (\(270 \times 1.67\) ns). The load change takes its CPI from 2.7 to 2.3 and the time to 460 ns. Nearly the same gain, from a 20% faster clock on one side and from one cell of one row on the other: CPI is a lever as big as frequency.

  2. Still on the exam preset: can you make CPU2 win without touching its clock? Predict how low its load cost would have to go.
    What you should see

    Not with the LOAD row alone: even at 0 cycles for loads, \(CPI_2 = 1.8\) and the time is 900 ns, still above 540 ns. At 200 MHz every cycle costs 5 ns; the clock factor is 2.5 against CPU1 and no single row of the mix can pay for it. Both levers matter, and here the clock lever is the bigger one.

  3. Switch to the "Notes, Example 3" preset. The twin differs in one cell (loads take 2 cycles instead of 4). Predict its CPI and the speedup, then look.
    What you should see

    \(CPI = 2.23 - 0.21 \times 2 = 1.81\), 362 ns against 446 ns: the twin is 1.23 times faster. Halving the cost of one class that is 21% of the mix gave 23%.

  4. Switch to "MIPS inversion". Read the two MIPS values first, then the two times. Which machine is faster, and why does MIPS point the other way?
    What you should see

    A: 833 MIPS, 12 ms. B: 400 MIPS, 10 ms. B is faster. MIPS counts instructions per second, and A executes 2.5 times more instructions to do the same work (floating-point arithmetic emulated with many integer instructions). The insight this widget is built for: neither MIPS nor the clock frequency is performance; only the product \(IC \times CPI \times T_{CLK}\) is.

CPU time = IC × CPI × TCLK: a change in any one factor is worth exactly as much as the same change in any other.

MIPS: a rate of instructions, not of work

MIPS, millions of instructions per second, is the throughput of instructions. The notes give two equivalent forms (eq. 21–22), and you should be able to pass from one to the other: substitute \(\text{CPU time} = IC \times CPI / f_{CLK}\) into the second and the \(IC\) cancels.

\[ \text{MIPS} = \frac{f_{CLK}}{CPI \times 10^6} \] \[ \text{MIPS} = \frac{IC}{\text{CPU time} \times 10^6} \]
\(f_{CLK}\) in MHz
then simply \(\text{MIPS} = f_{CLK}/CPI\): CPU1 gives \(500/2.7 = 185\), CPU2 gives \(200/2.4 = 83\)

Why do the notes warn that "higher MIPS does not necessarily mean better performance"? Because MIPS does not account for what an instruction does. Hennessy & Patterson's classic case (background, not in the notes) is a machine with optional floating-point hardware. With floating point emulated in software a program executes 10 million instructions at CPI 1.2 on a 1 GHz clock: 12 ms, 833 MIPS. With the FP unit the same program is 4 million instructions at CPI 2.5: 10 ms, 400 MIPS. The faster configuration has the lower MIPS, because each of its instructions does more. That is the third puzzle of the hook. In general MIPS depends on the instruction set, varies from program to program on the same machine, and can even vary inversely with performance.

When is MIPS harmless? When the two machines run the same program with the same instruction set, so that \(IC\) is the same: then the MIPS ratio equals the ratio of the times. The June 2025 pair is that case, \(185/83 = 2.22\), the same 2.22 as before. In the exam, compute the CPU times anyway: that is what the question asks for, and the time ratio is the definition of "faster".

"A higher clock frequency means a faster machine." Frequency is one of three factors. The June 2025 CPU1 has a 2.5 times faster clock and is 2.22 times faster; raise its clock further and its loads will cost still more cycles. The only safe comparison is the product.

Amdahl's law: only the fraction moves the ceiling

A 60-minute commute: 24 minutes (40%) on the motorway, 36 minutes on city streets. You buy a car ten times faster on the motorway. The motorway part shrinks from 24 minutes to 2.4; the city part stays 36; the trip now takes 38.4 minutes. Speedup: \(60/38.4 = 1.56\). Now imagine a teleporter for the motorway. The trip still takes 36 minutes: speedup 1.67. Nothing you do to the motorway can beat 1.67. To go faster you must attack the 36 minutes you did not touch.

That is Amdahl's law. \(F\) is the fraction of the original execution time affected by the enhancement, \(S\) the speedup of that part alone. The notes give the result; here is where it comes from.

  1. Call the old execution time \(T\). The enhancement touches a part worth \(F\,T\); the rest, \((1 - F)\,T\), is untouched.

  2. The touched part becomes \(S\) times faster, so it now takes \(F\,T / S\). The new time is the notes' eq. 23:

    \[ T' = (1 - F)\,T + \frac{F\,T}{S} \] \[ T' = \Big[(1 - F) + \frac{F}{S}\Big]\, T . \]
  3. The overall speedup is old time over new time; \(T\) cancels (eq. 24):

    \[ \text{Speedup} = \frac{T}{T'} = \frac{1}{(1 - F) + \dfrac{F}{S}} . \]
  4. Let \(S \to \infty\): the term \(F/S\) vanishes and only the untouched part is left (eq. 26). This is the ceiling, and it depends on \(F\) alone:

    \[ \text{Speedup}_{\max} = \frac{1}{1 - F} . \]
  5. The inverse question, "which \(F\) do I need for a target speedup with a given \(S\)?": solve eq. 24 for \(F\).

    \[ F = \frac{1 - \dfrac{1}{\text{Speedup}}}{1 - \dfrac{1}{S}} . \]
\[ \text{Speedup}(E) = \frac{1}{(1 - F) + \dfrac{F}{S}} \] \[ \text{Speedup}_{\max} = \frac{1}{1 - F} \]
\(F\)
fraction of the original execution time that the enhancement affects (Fraction\(_E\) in Hennessy & Patterson)
\(S\)
speedup of the enhanced part (Speedup\(_E\))

The notes' Example 4 (p. 252) is the commute in disguise: a unit 10 times faster on computation, and the CPU busy with computation 40% of the time. \(1/(0.6 + 0.04)\), that is \(1/0.64 = 1.5625\), about 1.56; with \(S \to \infty\), \(1/0.6 = 1.67\). "Even if the improvement is 10×, the overall speedup is only about 1.56×." The two bars below are the before and after of this example.

1 − F = 0.6 F = 0.4 36 min 24 min 60 min, speedup 1

Before: \(F = 0.4\) of the time can be improved

1 − F = 0.6 F / S = 0.04 36 min 2.4 min 38.4 min, speedup 1.56

After: that part is 10× faster, \(S = 10\)

Fig. 2. Amdahl's law as a before/after pair. The grey part never moves; the dashed outline is the time that disappeared. Even with \(S = \infty\) the bar cannot get shorter than the grey part: \(1/(1 - F) = 1.67\).

The exam likes the inverse question. The quiz of 8 January 2026, as the notes' exam chapter reproduces it (pp. 502–503), asks which fraction of the execution time must be enhanced, with \(S = 10\), to obtain an overall speedup of 4. Step 5 of the derivation:

\[ F = \frac{1 - 1/4}{1 - 1/10} = \frac{0.75}{0.9} = 0.833 , \]

that is about 83%. Not 40%, and not "4/10": almost the whole program has to be touched.

Hence the design rule the notes state, make the common case fast: it is \(F\), not \(S\), that decides. A modest 1.5× on 90% of the time gives \(1/(0.1 + 0.6) = 1.43\); a spectacular 100× on 20% of the time gives \(1/(0.8 + 0.002) = 1.25\). And the returns diminish: once the touched part is small, every further improvement of it is worth less, and the untouched part is the new bottleneck.

Gene Amdahl's paper has no formula in it. It is three pages long and states the idea in one sentence: the effort spent on high parallel processing rates is wasted unless sequential processing rates improve by "very nearly the same magnitude". The algebra you just derived came later, from others.

"Ten times faster on 40% of the time gives 4×." No: the gain is 1.56×, and the ceiling for \(F = 0.4\) is 1.67 whatever \(S\). Two more traps in the same family: \(F\) is a fraction of the original time, not of the new time and not of the instruction count; and two separate enhancements combine through their fractions, never by adding percentages — the overall speedup is

\[ \frac{1}{(1 - F_1 - F_2) + \dfrac{F_1}{S_1} + \dfrac{F_2}{S_2}} . \]

Amdahl explorer: push S, then push F

The bars are the before and after of the formula; the curve is the overall speedup as a function of \(S\), with the ceiling \(1/(1 - F)\) drawn dashed and the current \((S, \text{speedup})\) highlighted. The second mode turns the question around: you give a target speedup, the widget finds the \(F\) you need.

  1. Keep \(F = 0.4\) and push \(S\) from 10× up to 1000×. Predict first: does the overall speedup ever reach 2?
    What you should see

    Never. It goes from 1.56 at \(S = 10\) to 1.67 at \(S = 1000\) and the curve lies flat under the dashed ceiling 1.67. A hundredfold increase of \(S\) bought 7%.

  2. Put \(S\) back to 10× and raise \(F\) to 0.9. Predict the speedup, then compare with what \(S = 1000\) gave you a moment ago.
    What you should see

    5.26×, three times what \(S = 1000\) achieved at \(F = 0.4\), and the ceiling jumped from 1.67 to 10. The insight to take away: only \(F\) moves the ceiling; \(S\) only decides how close to it you get.

  3. Switch to "solve for F", target 4, \(S = 10\)×. Predict the required fraction before reading it.
    What you should see

    \(F = 83\%\): the January 2026 quiz. The bars show it: to cut the time to a quarter you must shrink almost all of it.

  4. Same target 4, but lower \(S\) to 2×. What happens, and what is the smallest \(S\) that makes the target reachable at all?
    What you should see

    The required \(F\) exceeds 1: not reachable. With \(S = 2\) even improving 100% of the time only doubles the speed. The target 4 needs \(S \ge 4\), and at \(S = 4\) exactly you need \(F = 1\). The log slider cannot stop exactly at 4: it shows 3.98× (\(F\) would be 100.2%, not reachable) and then 4.47× (\(F = 97\%\)).

You will meet the same formula once more, near the end of the course: on a multiprocessor \(F\) is the fraction of the program that runs in parallel and \(S\) the number of cores, and 95% parallel code on 100 cores gives \(1/(0.05 + 0.0095) = 16.8\), not 100.

Speedup = 1 / ((1 − F) + F/S), never above 1 / (1 − F): the part you did not improve sets the ceiling.

Pipeline arithmetic: cycles = IC + 4 + stalls

Lesson 1 built the five-stage pipeline; this section counts its cycles the way the exam does. First, what pipelining buys and what it does not. It increases instruction throughput: once the pipeline is full, one instruction completes per cycle. It does not reduce the latency of a single instruction, which still walks through all five stages; in fact the latency grows slightly, for two reasons the notes list on p. 253. Imbalance among the stages: the clock cycle must fit the slowest stage, so the faster stages idle for part of every cycle. Overhead of pipeline control: the pipeline registers between the stages, their set-up time and the clock skew add to every cycle. So \(T_{CLK}\) must be at least the time of the slowest stage plus the register overhead (the notes write a plain "greater than"); that overhead is why five stages do not divide the cycle by five. Designers balance the stages, and sometimes split a slow one in two, which is how pipelines get deeper.

one clock period = 2.5 ns, set by the slowest stage (EX) IF ID EX ME WB 2.0 ns 1.5 ns 2.5 ns 2.0 ns 1.0 ns idle time
Fig. 3. The clock is set by the slowest stage. The blue part of each period is work, the dashed orange part is idle time. Balancing the stages, or splitting the slow one, shortens the period; the pipeline registers add their own overhead to every period.

One iteration, counted by hand

Take the kind of loop body every exam paper uses, numbered I0 to I4 as the papers number instructions (older papers write $F2 and $R1; the 2026 paper drops the dollar sign, and so does this course).

LOOP: LD    F2, 0(R1)     ; I0
      FADD  F4, F2, F2    ; I1
      SD    F4, 0(R1)     ; I2
      ADDUI R1, R1, 8     ; I3
      BNE   R1, R2, LOOP  ; I4

Machine assumptions, stated the way a paper states them: the 5-stage pipeline IF ID EX ME WB of lessons 1 and 2 with forwarding; one instruction fetched per cycle; the FADD occupies EX for one cycle like any ALU operation (lesson 7 gives floating point its own longer pipeline); \(m = 5\) instructions per iteration and \(k = 2\) stall cycles per iteration: one load-use stall at I1 (the FADD needs F2 one cycle too early) and one branch stall at I4. Why exactly those two is the business of lesson 2 and lesson 4; here only their number matters. First the iteration as if nothing stalled.

one finishes per cycle, from C5 C1 C2 C3 C4 C5 C6 C7 C8 C9 I0 LD IF ID EX ME WB I1 FADD IF ID EX ME WB I2 SD IF ID EX ME WB I3 ADDUI IF ID EX ME WB I4 BNE IF ID EX ME WB fill: 4 cycles
Fig. 4. The iteration with no stalls: I0 completes in cycle 5 and each following instruction one cycle later, so the last of the five completes in cycle \(5 + 4 = 9\). The four cycles in which nothing completes are the pipeline fill, paid once.

Now the real iteration, with its two stalls. The load-use bubble holds I1 in ID during cycle 4 and freezes everything behind it; the branch stall does the same in cycle 8. Each stall pushes every later write-back one cycle to the right.

One iteration run alone with \(k = 2\): the last write-back is in cycle \(11 = 5 + 4 + 2\).
Instruction1234567891011
I0 LD F2, 0(R1)IFIDEXMEWB
I1 FADD F4, F2, F2IFIDstallEXMEWB
I2 SD F4, 0(R1)IFstallIDEXMEWB
I3 ADDUI R1, R1, 8IFIDEXMEWB
I4 BNE R1, R2, LOOPIFIDstallEXMEWB

Count the last write-back: cycle 11. In general, instruction number \(j\) is fetched in cycle \(j\) plus the stalls before it and completes four cycles later, so the last of \(IC\) instructions completes in cycle \(IC + 4 + \text{stalls}\). This is the counting rule of the course, the notes' eq. 2 and eq. 27, and it is on the formula sheet with the same "+4".

\[ \text{Clock cycles} = IC + \text{Stall cycles} + 4 \] \[ CPI = \frac{IC + \text{Stall cycles} + 4}{IC} \] \[ \text{MIPS} = \frac{f_{CLK}}{CPI \times 10^6} \]
\(+4\)
the pipeline fill of a 5-stage pipeline, depth \(- 1\); for a pipeline of \(d\) stages it would be \(d - 1\)
stall cycles
every cycle in which the stream does not advance: data hazards, structural hazards, branches, cache misses

The notes' Example 6 (p. 28, repeated as Example 5 on p. 254) has exactly the numbers of this iteration: \(IC = 5\), 2 stall cycles, 500 MHz. Cycles \(5 + 2 + 4 = 11\); \(CPI = 11/5 = 2.2\); \(\text{MIPS} = 500/2.2 = 227\). And without the stalls? Not CPI 1.

Use the "+4" when the question is about the 5-stage pipeline: "how many cycles, which CPI, which MIPS for this code with or without forwarding". The other families of exercises count differently.

Loops: one iteration against the whole run

A loop with \(m\) instructions per iteration, \(k\) stall cycles per iteration and \(n\) iterations is the exam's favourite shape, and the formula sheet carries two sets of numbers for it. The per-iteration figures treat one iteration as if it ran alone, fill included (notes eq. 30–33): \(IC_{iter} = m\), cycles \(= m + k + 4\), \(CPI_{iter} = (m + k + 4)/m\), and MIPS from that CPI. For the loop above: 11 cycles and \(CPI_{iter} = 2.2\), the numbers you just counted. The whole run is different, because the fill is paid once, not \(n\) times.

  1. Over \(n\) iterations the instruction count is \(IC = m\,n\). Each iteration costs its \(m\) issue cycles and its \(k\) stall cycles; the fill is paid once (eq. 34–35):

    \[ \text{Clock cycles} = m\,n + k\,n + 4 . \]
  2. Divide by the instruction count. The exact CPI of the run depends on \(n\):

    \[ CPI(n) = \frac{m\,n + k\,n + 4}{m\,n} \] \[ CPI(n) = 1 + \frac{k}{m} + \frac{4}{m\,n} . \]
  3. Let \(n \to \infty\): the last term, the fill spread over all the instructions, goes to zero (eq. 36). What remains is the asymptotic CPI, which the formula sheet writes \(CPI_\infty = CPI_{AS}\):

    \[ CPI_{AS} = \frac{m + k}{m} = 1 + \frac{k}{m} \] \[ \text{MIPS}_{AS} = \frac{f_{CLK}}{CPI_{AS} \times 10^6} . \]
  4. Read the result: \(k/m\) is the number of stall cycles per instruction. So the asymptotic CPI of a loop is "1 + stall cycles per instruction", the realistic CPI of the notes' eq. 39, and the only way to improve it is to cut \(k\) or to make \(m\) larger for the same \(k\).

The loop above (\(m = 5\), \(k = 2\)) at 500 MHz, for a growing number of iterations.
\(n\)\(IC = 5n\)cycles \(= 5n + 2n + 4\)CPIMIPS
15112.200227
1050741.480338
1005007041.408355
∞——1.400357

"CPI per iteration = \((m + k + 4)/m\), so the loop's CPI is 2.2." Only one isolated iteration has CPI 2.2; the run of 100 has 1.408 and the limit is 1.4. The notes' p. 255 makes this harder to see: its asymptotic block is headed "Total Instruction Count per iteration", "Total Clock Cycles per iteration", "Cycles Per Instruction per iteration" for \(m \times n\), \(mn + kn + 4\) and \(CPI_{AS}\), which are totals over all \(n\) iterations and their limit. Read "per iteration" there as "of the whole run". A paper asking for "the CPI of a single iteration" wants \((m + k + 4)/m\); one asking for the asymptotic CPI wants \((m + k)/m\).

Loop CPI explorer: the fill vanishes, the stalls stay

The bar splits the clock cycles of the whole run into useful issue cycles \(n\,m\), stall cycles \(n\,k\) and the four fill cycles. The plot is \(CPI(n)\) with its asymptote \(1 + k/m\) and the ideal CPI 1; the highlighted point is the current \(n\).

  1. Set \(n = 1\) with \(m = 5\), \(k = 2\). Predict the CPI, then move \(n\) to 100 and to 1000 and watch the point slide along the curve.
    What you should see

    At \(n = 1\) the CPI is \(11/5 = 2.2\), the per-iteration figure (the notes' Example 5). At \(n = 100\) it is 1.408, at \(n = 1000\) it is 1.4008: the point lies on the dashed asymptote 1.4 and the fill segment of the bar has shrunk to a sliver.

  2. With \(n = 100\), predict what "Remove one stall" does to the asymptotic CPI and MIPS; then, instead of removing a stall, double \(f_{CLK}\). Which readouts move in each case?
    What you should see

    One stall less: \(CPI_{AS}\) from 1.4 to 1.2, MIPS from 357 to 417, CPU time from 1408 ns to 1208 ns. Doubling the clock: MIPS and CPU time change, every CPI stays. The clock changes the length of a cycle; stalls change the number of cycles. The insight of this widget: the fill is a fixed tax paid once, the stalls are a tax on every iteration, so \(k/m\) is what you optimise.

  3. Keep \(k = 2\) and raise \(m\) from 5 to 20. Predict the new asymptotic CPI before you move the slider.
    What you should see

    \(1 + 2/20 = 1.1\). The same two stalls are spread over four times as many instructions. Spreading stalls over a longer body is what loop unrolling does in lesson 15.

  4. Remove both stalls. What do the asymptotic CPI and the pipeline speedup read, and why does the exact CPI still not say 1.000?
    What you should see

    \(CPI_{AS} = 1\) and the speedup over an unpipelined machine with 5 cycles per instruction is exactly 5, the pipeline depth. The exact CPI reads 1.008 at \(n = 100\): the four fill cycles never disappear, they only get diluted.

Ideal and realistic CPI, and the speedup of a pipeline

The notes close the chapter with two short formulas (eq. 38–39): the ideal CPI of a pipelined processor is 1, one instruction per cycle after the fill; the realistic CPI is \(1 + \) stall cycles per instruction, and the stalls come from four sources: structural hazards (a resource conflict), data hazards (a dependence), control hazards (a branch) and memory stalls (a cache miss). You have just seen the same formula as \(1 + k/m\). One correction to that page is worth points.

How much does a pipeline buy? Compare the average time per instruction on an unpipelined machine with the pipelined one. The notes' p. 256 derives it in four lines; one of them is misprinted.

  1. By definition (eq. 40), the speedup is the ratio of the average execution times per instruction, and each is a CPI times a cycle time (the instruction count is the same and cancels):

    \[ \text{Speedup} = \frac{CPI_{unp} \times T_{clk,unp}}{CPI_{pipe} \times T_{clk,pipe}} . \]
  2. Ignore the register overhead and assume balanced stages: the two cycle times are equal and cancel too. What is left is the ratio of the CPIs, and the pipelined CPI is \(1 + \) stall cycles per instruction (eq. 41, corrected):

    \[ \text{Speedup} = \frac{CPI_{unp}}{CPI_{pipe}} \] \[ \text{Speedup} = \frac{CPI_{unp}}{1 + \text{stalls / instruction}} . \]
  3. Assume every instruction takes the same number of cycles on the unpipelined machine, and that this number is the number of stages (the stages are the same work, done one after the other). Then \(CPI_{unp}\) is the pipeline depth (eq. 42):

    \[ \text{Speedup} = \frac{\text{depth}}{1 + \text{stalls / instruction}} . \]
  4. With no stalls the speedup is the depth (eq. 43): a 5-stage pipeline can give at most 5×, and only without stalls, with balanced stages and with no register overhead. For the loop above, \(k/m = 0.4\): \(5/1.4 = 3.57\); with one stall removed, \(5/1.2 = 4.17\).

  5. If the only stalls are branch stalls, the stall cycles per instruction are the branch frequency times the branch penalty (eq. 44–45, "PSCIB"):

    \[ \text{Speedup} = \frac{\text{Pipeline depth}}{1 + b \times p} . \]

    With 20% branches costing 3 cycles each, \(5/1.6 = 3.125\); cut the penalty to 1 and the pipeline is back to 4.17. That is the next lesson's job.

Why do deeper pipelines not simply give bigger speedups? Two reasons hidden in the assumptions. Each new stage adds its register overhead to the cycle, so the clock does not shrink in proportion. And the stall penalties grow with the depth: a branch resolved \(p\) stages after fetch costs \(p\) cycles, a load's value appears later in a longer pipeline. The arithmetic that promises depth-fold speedups charges for the depth in the denominator.

Back to the three puzzles

CPU1 beats CPU2 with the worse CPI because CPU time is \(IC \times CPI \times T_{CLK}\): the clock factor, 2.5, beats the CPI factor, 1.125, and their quotient is 2.22. It is not 2.5 times faster because its instructions cost more cycles on the faster clock, the CPI factor again. And the 833-MIPS machine loses because MIPS counts instructions, and it executes 2.5 times more of them for the same work. Three puzzles, one formula.

Cycles = IC + 4 + stalls, paid once for the fill and once per stall; for a loop the fill fades and CPI → 1 + k/m.

Exam-style questions

The first exercise is Exercise 3 of the 10 June 2025 paper in its own words; the model answer is recomputed, not an official solution. Write the weighted sums out in full on the paper: the examiner follows the arithmetic, not only the result.

PERFORMANCE EVALUATION. Given CPU1 with clock frequency 500 MHz and CPU2 with clock frequency 200 MHz, let's consider the two CPUs execute a kernel of 100 instructions with the following frequencies of occurrence and clock cycles:

Instruction TypeInstruction FrequencyCPU1 Clock CyclesCPU2 Clock Cycles
ALU30%21
LOAD10%86
STORE20%23
JUMP30%22
BRANCH10%33

How much is the average CPI for each CPU? CPI1 = … CPI2 = … How much is the CPU time for each CPU? CPUtime1 = … CPUtime2 = … How much is CPU1 faster than CPU2?

Show model answer

CPI1 = 0.3 × 2 + 0.1 × 8 + 0.2 × 2 + 0.3 × 2 + 0.1 × 3 = 0.6 + 0.8 + 0.4 + 0.6 + 0.3 = 2.7

CPI2 = 0.3 × 1 + 0.1 × 6 + 0.2 × 3 + 0.3 × 2 + 0.1 × 3 = 0.3 + 0.6 + 0.6 + 0.6 + 0.3 = 2.4

TCLK1 = 1 / 500 MHz = 2 ns; TCLK2 = 1 / 200 MHz = 5 ns.

CPUtime1 = IC × CPI1 × TCLK1 = 100 × 2.7 × 2 ns = 540 ns; CPUtime2 = 100 × 2.4 × 5 ns = 1200 ns.

CPU1 is faster by the ratio of the execution times: 1200 / 540 = 2.22 times faster, i.e. 122% faster (Perf(CPU1) = (1 + 122/100) × Perf(CPU2)), although its CPI is higher: the clock factor 2.5 outweighs the CPI factor 2.7 / 2.4 = 1.125.

Three things earn the points: the two weighted sums written term by term, the conversion of each frequency to a cycle time in ns before the multiplication, and "faster" expressed as the ratio of the times (2.22×, 122%), not as a difference, not as the CPI ratio and not through MIPS. Part 2 of the same exercise, CPU3 with cache misses, needs the memory-stall formula of lesson 24.

A loop body of m = 6 instructions is executed n = 200 times on the 5-stage RISC pipeline at 2 GHz; each iteration suffers k = 2 stall cycles. Compute: (a) the clock cycles and the CPI of a single iteration; (b) the total clock cycles of the loop; (c) the CPI of the whole loop and the asymptotic CPI; (d) the asymptotic MIPS; (e) the CPU time of the loop.

Show model answer

(a) Single iteration: cycles = m + k + 4 = 6 + 2 + 4 = 12; CPIiter = 12 / 6 = 2.0.

(b) Whole loop: IC = m × n = 1200; clock cycles = n × (m + k) + 4 = 200 × 8 + 4 = 1604 (the fill is paid once).

(c) CPI = 1604 / 1200 = 1.337; CPIAS = (m + k) / m = 8 / 6 = 1.333.

(d) MIPSAS = fCLK / (CPIAS × 106) = 2000 MHz / 1.333 = 1500 MIPS.

(e) TCLK = 1 / 2 GHz = 0.5 ns; CPU time = 1604 × 0.5 ns = 802 ns.

The classic mistake is to add 4 to every iteration (200 × 12 = 2400 cycles) or to forget it for the single iteration (8 cycles, CPI 1.33). Note how close the exact CPI (1.337) already is to the asymptotic one (1.333) after 200 iterations.

An enhancement gives a speedup S = 10 to the part of the execution it affects. Which fraction F of the original execution time must be affected to obtain an overall speedup of 4? Give F as a decimal fraction (three digits).

Show model answer

Speedup = 1 / ((1 − F) + F / S) = 4 ⇒ (1 − F) + F / 10 = 0.25 ⇒ 1 − 0.9 F = 0.25 ⇒ F = 0.75 / 0.9 = 0.833 (83% of the execution time).

This is the 8 January 2026 quiz as the notes reproduce it (single answer, "motivate your answer"; its options were 55%, 83%, 45%, 40% and 25%). Check the answer the way the examiner would: 1 / (1/6 + 1/12) = 1 / (3/12) = 4. The tempting distractors are 40% (the "4/10" guess) and 25% (the reciprocal of the target, 1/4).

Explain the main concepts and benefits of each one of the following: 1. the CPU time equation; 2. the weighted average CPI of an instruction mix; 3. MIPS as a performance metric and its limits; 4. Amdahl's law; 5. the pipeline fill and the formula Clock cycles = IC + Stall cycles + 4; 6. the asymptotic CPI of a loop.

Show model answer

1. CPU time = IC × CPI × TCLK = IC × CPI / fCLK: the instructions executed, times the average clock cycles per instruction, times the cycle time. Each factor is set by a different level (compiler and ISA for IC; organisation for CPI; technology and pipeline depth for TCLK) and they interact (a deeper pipeline shortens the cycle but adds stalls). Benefit: it predicts the effect of a design change and makes execution time, the only reliable metric, computable from measurable factors.

2. Total cycles = Σ CPIi × Ii; dividing by IC gives CPI = Σ CPIi × Fi with Fi = Ii / IC the frequency of class i. Benefit: the CPI of a program on a machine from a mix table (e.g. 2.7 vs 2.4), without executing it; it shows which class dominates the time.

3. MIPS = fCLK / (CPI × 106) = IC / (CPU time × 106): millions of instructions per second. Limits: it depends on the instruction set and on the program, and it ignores the work per instruction, so it can vary inversely with performance (software FP: more instructions, higher MIPS, longer time). It is valid only to compare the same program with the same IC; otherwise compare CPU times.

4. If a fraction F of the original execution time is made S times faster, the new time is ((1 − F) + F / S) × old time and the speedup is 1 / ((1 − F) + F / S), bounded by 1 / (1 − F) as S → ∞. Benefit: it tells where to invest ("make the common case fast") and bounds the return of any single enhancement; e.g. F = 0.4, S = 10 gives 1.56, at most 1.67.

5. In a 5-stage pipeline the first instruction completes in cycle 5 and each following one a cycle later, so IC instructions complete in IC + 4 cycles (the 4 fill cycles are the depth minus one, paid once); each stall cycle delays everything behind it by one cycle: Clock cycles = IC + Stall cycles + 4, CPI = cycles / IC, MIPS = fCLK / (CPI × 106). It gives the throughput of pipelined code from a cycle table (e.g. 5 instructions, 2 stalls: 11 cycles, CPI 2.2).

6. For a loop of m instructions and k stall cycles per iteration run n times, cycles = n(m + k) + 4 and CPI(n) = 1 + k/m + 4/(mn) → CPIAS = (m + k)/m = 1 + k/m as n → ∞: the fill becomes negligible and the performance is governed by the stall cycles per instruction, so minimising k (or spreading it over a longer body) is what matters. The ideal CPI 1 is reached only with k = 0.

The paper's open question gives about five lines per sub-point: a definition, the formula with its symbols explained, the benefit, and one number as an example. A concept without its "why" (what the technique buys) loses the point.

Program P runs in 10 s on machine A and in 15 s on machine B. Which statement is correct? (SINGLE ANSWER)

  • Answer 1: A is 33% faster than B 33% is the time A saves as a fraction of B's time, (15 − 10)/15; "faster" is defined on the ratio of the times.
  • Answer 2: A is 50% faster than B Time(B) = (1 + n/100) × Time(A): 15 = 1.5 × 10, so n = 50.
  • Answer 3: B is 50% faster than A B is the slower machine: it takes more time.
  • Answer 4: A is 1.33 times faster than B The ratio of the times is 15/10 = 1.5, not 1.33.
Show model answer

Answer 2: Perf(A)/Perf(B) = Time(B)/Time(A) = 15/10 = 1.5 = 1 + 50/100.

The notes' Example 2. The "33%" trap is the one distractor the examiner expects to catch people with.

On a 5-stage pipeline with no stalls, how many clock cycles do N instructions take? (SINGLE ANSWER)

  • Answer 1: 5N That is the unpipelined count: 5 cycles each, no overlap.
  • Answer 2: N + 4 The first instruction completes in cycle 5, the N-th in cycle N + 4: the fill of depth − 1 cycles is paid once.
  • Answer 3: N Only asymptotically: the fill never disappears, it is diluted.
  • Answer 4: N + 5 Off by one: the fill is depth − 1 = 4 cycles, because the cycle in which the first instruction completes is already one of the N.
Show model answer

Answer 2: Clock cycles = IC + Stall cycles + 4 with Stall cycles = 0.

Fig. 4: five instructions, cycles 1 to 9.

Which of the following statements are correct? (MULTIPLE ANSWERS)

  • Answer 1: Pipelining increases the instruction throughput but does not reduce the execution time of a single instruction Every instruction still walks through all the stages; only the overlap changed (notes, p. 253).
  • Answer 2: The ideal CPI of a single-issue 5-stage pipeline is 1 One instruction completes per cycle once the pipeline is full; stalls and the fill push the real CPI above 1.
  • Answer 3: A higher clock frequency always gives a shorter CPU time CPU time = IC × CPI × TCLK: a faster clock can raise the CPI (loads cost more cycles), as in the June 2025 exercise.
  • Answer 4: A 4-issue processor can have a CPI below 1 Its ideal CPI is 1/4 = 0.25; "CPI is always greater than 1" holds for single issue only.
  • Answer 5: With a large enough S, Amdahl's overall speedup can exceed 1 / (1 − F) 1 / (1 − F) is the limit for S → ∞; no S reaches it, let alone exceeds it.
Show model answer

Answers 1, 2 and 4.

Two of the three distractors are the "always" statements of this lesson's red pens; the third is the frequency fallacy of the hook.

Check yourself

CPU1 (CPI 2.7, 500 MHz) beats CPU2 (CPI 2.4, 200 MHz) on the same 100 instructions. Which sentence explains it?

  • CPU1 has the higher MIPS, and MIPS is performance Here MIPS happens to agree with the times because IC is the same, but MIPS is not the reason: it is a consequence of the same two factors.
  • CPU time = IC × CPI × TCLK: the cycle-time factor (2.5) outweighs the CPI factor (1.125) 2.5 / 1.125 = 2.22, exactly the measured ratio of the times.
  • CPU2's lower CPI means it executes fewer instructions CPI says nothing about the instruction count; both execute the same 100 instructions.

A straight-line program of 20 instructions suffers 3 stall cycles on the 5-stage pipeline. How many clock cycles does it take?

  • 23 You forgot the fill: the first instruction needs four extra cycles before anything completes.
  • 24 You forgot the stalls: each one delays every later instruction by one cycle.
  • 27 IC + 4 + stalls = 20 + 4 + 3.
  • 100 That is 5 cycles each with no overlap at all: the unpipelined machine.

A loop body of 8 instructions suffers 2 stall cycles per iteration. What is the asymptotic CPI of the loop?

  • 1.75 That is (8 + 2 + 4)/8, the CPI of one iteration run alone, fill included. Over many iterations the fill fades.
  • 1.25 (m + k)/m = 10/8 = 1 + 2/8: one plus the stall cycles per instruction.
  • 0.8 That is 8/10, the inverse; CPI of a single-issue pipeline cannot go below 1.
  • 3 Stalls per iteration is 2, not per instruction; and CPI counts cycles per instruction, not per iteration.

80% of a program's execution time can be made parallel. The largest overall speedup that any number of cores can give is

  • 80 The fraction is not the speedup; it sets the ceiling through 1/(1 − F).
  • 5 1/(1 − 0.8) = 5: the 20% that stays sequential cannot shrink.
  • 4 4 is 0.8/0.2, the ratio of the two parts, not the limit of 1/((1 − F) + F/S).
  • unbounded Only with F = 1; any untouched part puts a ceiling on the speedup.

Which of these changes lower the CPI of a given program on a given 5-stage pipeline? Select all that apply.

  • Adding the forwarding paths Fewer data-hazard stalls, fewer cycles for the same instructions.
  • A shorter clock cycle The cycle time is the third factor of the Iron Law; it does not change the number of cycles (and may raise it, if memory now costs more cycles).
  • A cache with a lower miss rate Memory stalls are stall cycles too (the notes' fourth source), and they count in the CPI.
  • A compiler that fills the load-use slot with an independent instruction Same instruction count, one stall less per load-use pair: lower CPI.
  • A higher MIPS rating of the machine MIPS is computed from the CPI and the clock; it is not a cause of anything.

CPI counts cycles per instruction: anything that removes stall cycles lowers it, anything that only shortens the cycle or only changes the instruction count does not.

Machine X is rated 833 MIPS and runs program P in 12 ms. Machine Y is rated 400 MIPS and runs P in 10 ms. Which is faster on P?

  • X, because 833 > 400 MIPS counts instructions, not work: X executes more instructions to do the same job.
  • Y, because 10 ms < 12 ms Execution time is the definition of performance; Y is 1.2 times faster.
  • It cannot be told without the clock frequencies The times are given; the frequencies would only tell you how the times came about.

A 5-stage pipeline suffers 0.25 stall cycles per instruction. Its speedup over an unpipelined machine that takes 5 cycles per instruction at the same clock is

  • 5 5 is the ideal, with no stalls at all.
  • 4 Depth / (1 + stalls per instruction) = 5 / 1.25 = 4.
  • 2.22 That is 5 / (1 + 1.25): the misprinted eq. 41 of the notes, which counts the ideal cycle twice.
  • 20 5 × 4 multiplies where the formula divides.

Key take-aways

What to watch and read