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

S4 · Lesson 1 · Performance and the iron law

Execution time from instruction count, CPI and clock rate, benchmarks, and the memory wall

Computer architecture is the art of spending a transistor and power budget to make programs run faster, and "faster" needs a precise meaning before any design choice can be judged. The only honest measure is the time a real program takes. That time factors into three terms (how many instructions run, how many cycles each takes on average, and how long a cycle is), and every architectural idea in this course attacks one of them, usually at some cost to another. This course builds on C8's processor and S3's hardware to the depth of a senior architecture course, using Hennessy and Patterson's quantitative approach: measure, model, then design.

  • Average time per instruction against clock frequency for a core whose pipeline CPI is CPIcore and which misses to main memory m times per instruction, each miss taking a fixed tmem nanoseconds.
  • The core's part, CPIcore/f, shrinks as the clock rises, but the memory part, mtmem, doesn't, because DRAM's latency is fixed in nanoseconds.
  • Raise m: past a point a faster clock barely helps. That's the memory wall, the reason a third of this course is about memory.

Predict

A core with a CPI of 1 also misses to a 100 ns memory once every 100 instructions. Its clock is raised from 1 GHz to 4 GHz. How much faster do programs run?

Name it

The iron law

CPU time=IC×CPI×Tclk=IC×CPIf
  • Instruction count (IC): set by the program, the compiler and the ISA.
  • Cycles per instruction (CPI): set by the microarchitecture and the memory system; a mix's CPI is ∑ifiCPIi. Its reciprocal is IPC.
  • Clock period: set by the circuit design and the pipeline depth.

Improving one term often worsens another: a more powerful instruction lowers IC but may raise CPI or the period.

Memory stalls

CPI=CPIcore+missesinstruction×miss penalty in cycles

With the miss penalty fixed in nanoseconds, its cost in cycles grows with the clock rate.

Comparing machines

  • Speedup of B over A: timeAtimeB.
  • MIPS (f/(CPI×106)) ignores instruction count, so it can rank machines backwards.
  • Benchmarks such as SPEC report each program's ratio to a reference machine, combined by the geometric mean, (∏iri)1/n, the only mean whose ranking doesn't depend on which machine is the reference.
  • Performance per watt matters as much as performance from phones to data centers (lesson 3).

Worked example

A program runs 109 instructions at a CPI of 1.5 on a 2 GHz core. A new compiler cuts the instruction count by 20% but raises the CPI to 1.8. Which is faster, and which has the higher MIPS?

Show the solution
  1. Time with the old compiler. told=109×1.52×109s=0.75s
  2. Time with the new compiler. tnew=0.8×109×1.82×109s=0.72s so the new code is 4% faster.
  3. MIPS of each. old: 2000/1.5=1333 new: 2000/1.8=1111
  4. Why MIPS gets it wrong. MIPS ranks them the wrong way, because it ignores the 20% fewer instructions.

Answer the new compiler's code is 4% faster (0.72 s against 0.75 s), yet the old code has the higher MIPS (1333 against 1111).

Worked example

A new machine's speed ratios on three benchmarks are 2, 1.5 and 4. What single number does SPEC report, and why not the arithmetic mean?

Show the solution
  1. The geometric mean. SPEC reports the geometric mean of the ratios: G=(2×1.5×4)1/3=2.29
  2. The arithmetic mean. It is 2.5, but it gives a different ranking depending on which machine the ratios are taken against.
  3. Why the geometric mean is consistent. In a geometric mean of ratios the reference machine's times cancel, so the ranking doesn't depend on the reference.
  4. Its weakness. The geometric mean no longer corresponds to the time of any real workload.

Answer SPEC reports the geometric mean, 2.29, because unlike the arithmetic mean (2.5) it ranks machines the same whichever machine the ratios are taken against.

Worked example

A core with a base CPI of 1.0 runs at 2 GHz; 2% of its instructions miss to a memory 100 ns away. What is its CPI, and how much faster is it at 4 GHz with the same memory?

Show the solution
  1. CPI at 2 GHz. A 100 ns miss costs 200 cycles: CPI=1+0.02×200=5.0 which is 2.5 ns per instruction.
  2. CPI at 4 GHz. The same 100 ns is now 400 cycles: CPI=1+0.02×400=9.0 which is 2.25 ns per instruction.
  3. Compare the times. 2.5ns/2.25ns=1.11 Doubling the clock buys only 11%: that's the memory wall in one line.

Answer the CPI is 5.0 at 2 GHz; at 4 GHz it rises to 9.0, and the core is only 11% faster.

Check

A program runs 2 billion instructions at a CPI of 0.8 on a 3 GHz core. How long does it take?

Write units the way you normally would: 1.5 s and 1500 ms are the same answer.

Check

A program is 0.5 ALU instructions at CPI 1.2, 0.25 loads and stores at CPI 3, and the rest branches at CPI 3. What's its CPI?

Check

Machine A runs a program as 1 billion instructions at CPI 1.2 and 3 GHz; machine B needs 1.3 billion instructions at CPI 1.5 and 2.5 GHz. What's B's speedup over A?

Check

A core with CPI 0.8 misses 0.005 times per instruction to a 120 ns memory. Its clock goes from 2 GHz to 2× that. What's the speedup?

Check

What's the MIPS rating of a 2 GHz core with a CPI of 1.25?

Check

A machine's speed ratios on three benchmarks are 1.5, 0.8 and 6. What's the geometric mean?

Check

A program executes 1 × 10⁹ instructions at a CPI of 0.8 on a 3 GHz core.

(a)

How long does it run?

Write units the way you normally would: 1.5 s and 1500 ms are the same answer.

(b)

What MIPS rating does it get?

Check

A core with a base CPI of 0.5 misses to memory on 0.005 of its instructions; memory takes 100 ns, and the clock is 4 GHz.

(a)

What is its CPI?

(b)

How long does each instruction take on average?

Write units the way you normally would: 1.5 ns, 1500 ps and 0.0015 µs are the same answer.

Check

A machine's speed ratios against a reference on three benchmarks are a, b and c.

Step 1

What is their geometric mean?

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°.

Explain why

Why is execution time on real programs the only trustworthy performance measure, when clock rate, MIPS and peak FLOPS are all easier to quote?

Practice

Keep practicing

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