Recap of Lecture 3 and Homework Check
- Cost of die = wafer cost / (dies per wafer x die yield).
- A bigger die costs more than its area suggests.
- Availability = MTTF / (MTTF + MTTR).
- System failure rate = sum of part failure rates.
Homework check
- 30 cm wafer, $6,000, die 1.5 cm^2, D = 0.04, N = 13.5: dies, yield, cost?
- Server: 2 disks (1M h), power supply (200k h), motherboard (300k h): MTTF?
Today's Plan (50 minutes)
0-5
Recap and homework check Lecture 3
5-8
Plan and learning outcomes
8-16
Module 1: What is performance? time, throughput, 'n times faster'
16-28
Module 2: The CPU performance equation IC x CPI x clock cycle time
28-35
Module 3: What changes IC, CPI and clock and how to report results
35-43
Class activity four short numericals
43-50
Mistakes, quiz and homework
Learning Outcomes (SLOs)
By the end of this lecture you will be able to:
SLO 4.1
Differentiate execution time, throughput and CPU time, and state how many times faster one computer is.
→ CLO2 · C2 Understand
SLO 4.2
Apply the CPU performance equation to compare computers and find average CPI from an instruction mix.
→ CLO2 · C3 Apply
SLO 4.3
Identify which design decisions change instruction count, CPI and clock rate.
→ CLO2 · C2 Understand
CLO2: Measure and report computing performance using benchmarks, metrics, the CPU performance equation and Amdahl's law.
Module 1: What Is Performance?
Two different questions: how fast for me, and how much work in total
Execution Time vs Throughput
Execution time
Throughput
- Time to finish one task, start to end.
- What one user cares about: how long does my program take?
- A faster clerk at the NADRA counter.
- Total work per unit time (tasks per hour).
- What a data-center manager cares about.
- Opening more counters at the NADRA office.
In this lecture: We focus on execution time. Performance = 1 / execution time (less time = more performance).
How Many Times Faster?
- Performance(X) = 1 / Execution time(X)
- X is n times faster than Y:
- n = Time(Y) / Time(X)
- = Performance(X) / Performance(Y)
Rule
Put the slower (bigger) time on top, so n is greater than 1.
- Example: laptop takes 15 s, desktop takes 10 s
- n = 15 / 10 = 1.5 -> the desktop is 1.5 times faster
Say '1.5 times faster', not '50% faster' - the ratio is clear and cannot be misread.
Elapsed Time vs CPU Time
- $ time ./program (example output)
- real 0m10.200s <- elapsed time
- user 0m6.000s <- CPU, in program
- sys 0m1.500s <- CPU, in the OS
CPU time
- = user + sys
- = 6.0 + 1.5 = 7.5 s
- CPU busy 7.5/10.2 = 74%
Example: A bus journey's elapsed time includes waiting at stops; CPU time is only the time the bus is actually driving.
The CPU performance equation predicts CPU time, not elapsed time.
Module 2: The CPU Performance Equation
Time = instructions x cycles per instruction x time per cycle
The CPU Performance Equation
- CPU time = Instruction count x CPI x Clock cycle time
- = IC x CPI / Clock rate
- seconds instructions cycles seconds
- ------- = ------------ x ----------- x -------
- program program instruction cycle
IC
CPI
Clock cycle
Instructions executed (not lines of code)
Average clock cycles per instruction
1 / clock rate (2 GHz -> 0.5 ns)
Worked Example 1: Faster Clock, Slower Computer
1.17x
A is faster
with the slower clock
- A: 10^9 x 2.0 / 2x10^9 = 1.0 s
- B: 10^9 x 3.5 / 3x10^9 = 1.167 s
Lesson: Clock rate alone never decides performance; you need IC, CPI and clock. Like a bus with a higher top speed but more stops.
Average CPI from an Instruction Mix
- CPI = sum(F_i x CPI_i)
- = 0.5+1.0+0.3+0.4
- = 2.2
Notice
Loads are 20% of instructions but cause 45% of the cycles (1.0 / 2.2).
Instruction mix (the share of each kind of instruction a program executes).
Worked Example 2: Faster Loads
- Old CPI = 0.5 + 0.2 x 5 + 0.3 + 0.4 = 2.2
- New CPI = 0.5 + 0.2 x 2 + 0.3 + 0.4 = 1.6
- Speedup = Old time / New time = 2.2 / 1.6 = 1.375
- (IC and clock unchanged, so time is proportional to CPI)
1.375x
1.25x
speedup
even if the clock slows 10%
from faster loads only
2.2 / (1.6 x 1.1)
Module 3: What Changes IC, CPI and Clock?
Every design decision moves one or more of the three terms
Who Affects Each Term?
Link to Practical 2: The mul version had more instructions (29 vs 28). If mul takes 4 cycles, it also takes more cycles (35 vs 28).
Example 3: More Instructions, Less Time
Result: Sequence 2 runs more instructions but fewer cycles, so it is faster. Only total time counts.
Neither IC alone nor CPI alone is a reliable measure of performance - use CPU time.
Reporting Performance Results
Report everything
Why
- Hardware: processor, clock, cache, memory
- Software: OS, compiler, version, flags (-O2)
- Workload: program and input size
- Method: number of runs, how averaged
- Reproducibility: someone else must get the same result.
- 'It runs in 2 seconds' means nothing without the machine and the input.
Next lecture: Benchmarks (SPEC) and how to summarize many results with a mean.
Class Activity: Four Quick Numericals
7 min · pairs
Solve in pairs with a calculator. Show the formula you use.
A program takes 12 s on X and 8 s on Y. How many times faster is Y?
IC = 5 x 10^9, CPI = 1.6, clock = 4 GHz. Find the CPU time.
Mix: ALU 60% (CPI 1), memory 30% (CPI 4), branch 10% (CPI 3). Find average CPI.
P: 2.5 GHz, CPI 1.5. Q: 3 GHz, CPI 2.0. Same IC. Which is faster, and by how much?
Common Mistakes
Wrong idea
Correct idea
✗ The higher-GHz computer is faster.
✓ Time = IC x CPI / clock; a lower CPI can beat a higher clock.
✗ IC = number of lines in the program.
✓ IC = number of instructions executed (loops repeat lines).
✗ Fewer instructions always means faster.
✓ Fewer instructions can need more cycles (Example 3).
✗ Y is 1.5x faster means Time(Y) / Time(X) = 1.5.
✓ n = Time(slower) / Time(faster) = Time(X) / Time(Y).
Recap Quiz
Answer on paper in 3 minutes, then we check together.
Q1
Define performance in terms of execution time.
Q2
Write the CPU performance equation.
Q3
IC = 2 x 10^9, CPI = 1.5, clock = 3 GHz. CPU time?
Q4
Which term(s) does a bigger cache mainly change: IC, CPI or clock?
Q5
Why can a program with more instructions run faster?
Homework and Next Lecture
- Read Hennessy and Patterson, Chapter 1, sections 1.8 and 1.9 (the processor performance equation).
- Compiler: classes A, B, C have CPI 1, 2, 3. Sequence 1: 4 A, 2 B, 1 C. Sequence 2: 1 A, 1 B, 3 C. Find IC, cycles and CPI of each. Which is faster?
- From Practical 2: add-only z = 28 instructions; mul version = 29 (2 of them mul). If mul takes 4 cycles and all others 1, which version is faster?
NEXT LECTURE
Lecture 5: Benchmarks and Metrics
Kinds of benchmarks (SPEC, TPC), misleading metrics (MIPS, peak performance), and arithmetic vs geometric mean.