Recap of Lecture 5 and Homework Check
- Real programs in a suite are the most trusted benchmarks.
- MIPS = clock rate / (CPI x 10^6) - can rise while time rises.
- SPECratio = reference time / your time (bigger is better).
- Combine ratios with the geometric mean.
Homework check
- MIPS trap at 3 GHz:
- X: 6, 2, 1 billion of A, B, C
- Y: 4, 1, 2 billion (CPI 1, 2, 4)
- SPEC: ref 900, 1200, 600 s
- P: 90, 100, 75 s
- Q: 60, 150, 60 s
Today's Plan (50 minutes)
0-5
Recap and homework check Lecture 5
5-8
Plan and learning outcomes
8-18
Module 1: Three great ideas parallelism, locality, the common case
18-30
Module 2: Amdahl's law formula, worked example, the limit
30-38
Module 3: Choosing a design FP example, multicore, link to CPU equation
38-45
Class activity four Amdahl problems
45-50
Mistakes, quiz and homework
Learning Outcomes (SLOs)
By the end of this lecture you will be able to:
SLO 6.1
Explain three design principles - parallelism, locality and focusing on the common case - with examples.
→ CLO1 · C2 Understand
SLO 6.2
Apply Amdahl's law to find the overall speedup of an enhancement and its upper limit.
→ CLO2 · C3 Apply
SLO 6.3
Use Amdahl's law to compare two design alternatives and choose the better one.
→ CLO2 · C3 Apply
- CLO1: Describe the principles of computer design, including technology, cost and dependability trends.
- CLO2: Measure and report computing performance using benchmarks, metrics, the CPU performance equation and Amdahl's law.
Module 1: Three Great Ideas
Principles every computer designer uses
Idea 1: Take Advantage of Parallelism
System level
Processor level
Circuit level
- Many servers or cores share the requests.
- Many toll booths on the M-2 motorway.
- Pipelining: overlap the steps of many instructions (Unit 3).
- Wash, dry and iron different loads together.
Carry-lookahead adder finds all carries at once, not one by one.
Key point: parallelism is the main way to gain speed now that clock rates have stopped rising (Lecture 2).
Idea 2: The Principle of Locality
- sum = 0;
- for (i = 0; i < 100; i++)
- sum = sum + a[i];
90 / 10 rule
A program spends about 90% of its time in 10% of its code.
Temporal (time)
Spatial (space)
- Used now, used again soon: sum, i, the loop body.
- Your daily WhatsApp chats stay at the top.
- Used now, neighbours used soon: a[0], a[1], a[2]...
- After page 10 you read page 11.
Idea 3: Focus on the Common Case
In hardware
In daily life
- Addition rarely overflows: make normal addition fast, let overflow be slow.
- Practical 4: 'Other' used 20 of 42 cycles - improve it first.
NADRA opens extra counters for CNIC renewal - the common request - not for rare ones.
Question: how much faster does the whole program get if we speed up only one part? Amdahl's law answers this.
Module 2: Amdahl's Law
The gain is limited by the part you did not improve
A Trip from Lahore to Islamabad
1.17x
overall
5.5 / 4.7
3.67x
best possible
5.5 / 1.5
Lesson: the part you did not improve (city traffic) limits the speedup of the whole trip.
Amdahl's Law
- New time = Old time x ( (1 - F) + F / S )
- 1
- Speedup overall = -----------------
- (1 - F) + F / S
Two numbers
- F = fraction of the original time that can use the improvement.
- S = how many times faster that part becomes.
- Trip check: F = 4 / 5.5 = 0.727, S = 1.25
- Speedup = 1 / (0.273 + 0.727 / 1.25) = 1 / (0.273 + 0.582) = 1.17
F is a fraction of time, not a fraction of instructions or of code.
Worked Example 1: A Faster Web Server Processor
- F = 0.4 (computing), S = 10
- Speedup = 1 / (0.6 + 0.4 / 10)
- = 1 / (0.6 + 0.04)
- = 1 / 0.64 = 1.56
10x
1.56x
processor
server
the advert
what users feel
Limit: with an infinitely fast processor: 1 / 0.6 = 1.67. To go further, improve the I/O (the 60%).
The Limit: 1 / (1 - F)
Diminishing returns
Each extra x in S gives less and less. First make F large, then S.
Module 3: Using Amdahl's Law to Choose
Compare design alternatives with numbers, not guesses
Worked Example 2: Square Root or All FP?
Result: the small speedup on a big fraction (1.6x on 50%) beats the big speedup on a small fraction (10x on 20%).
Before buying hardware, ask: what fraction of the time does it help?
Worked Example 3: How Many Cores?
Efficiency
- = speedup / N
- 64 cores give 8.77x: only 14% of the hardware is used well.
Lesson: with 10% serial work, no number of cores gives more than 10x. Reduce the serial part first.
Amdahl's Law Meets the CPU Equation
- Lecture 4: CPI 2.2; loads 20% of instructions, CPI 5 -> 2
- F = time in loads = (0.2 x 5) / 2.2 = 0.4545, S = 5 / 2 = 2.5
- Amdahl: 1 / (0.5455 + 0.4545 / 2.5) = 1.375
- CPU equation: 2.2 / 1.6 = 1.375
Careful: F must be the fraction of time (cycles) = 45%, not of instructions (20%). Using 20% gives 1.14 - wrong.
Two methods, one answer: use whichever matches the data you have.
Class Activity: Four Amdahl Problems
7 min · pairs
Solve in pairs. Write F and S first, then the formula.
Half of a program's time can be made 2 times faster. Overall speedup?
80% of the time can be made 4 times faster. Overall speedup?
Only 60% of the time can be improved. What is the largest possible overall speedup?
Option A: make a 30% part 3x faster. Option B: make a 60% part 1.6x faster. Which is better?
Common Mistakes
Wrong idea
Correct idea
✗ 10x faster part = 10x faster program.
✓ Overall = 1 / ((1 - F) + F / S): the unimproved part limits you.
✗ F = fraction of instructions.
✓ F = fraction of the original execution time.
✗ More cores always give proportional speed.
✓ The serial part caps the speedup at 1 / (1 - F).
✗ Locality means data is close on the disk.
✓ Locality is about reuse in time and neighbours in address.
Recap Quiz
Answer on paper in 3 minutes, then we check together.
Q1
Name the two kinds of locality with one example each.
Q2
Write Amdahl's law and say what F and S mean.
Q3
F = 0.25, S = 5. Find the overall speedup.
Q4
A program is 70% parallel. What is the speedup with infinitely many cores?
Q5
Which design principle says 'favour the frequent case over the rare one'?
Homework and Next Lecture
- Read Hennessy and Patterson, Chapter 1, section 1.9 (quantitative principles and Amdahl's law).
- Cores: a program is 95% parallel. Find the speedup on 16 cores and the limit.
- Reverse Amdahl: a part can be made 10x faster. What fraction F of the time must it be to give 3x overall?
- From Practical 4: in the bill program, 'Other' used 20 of 42 cycles. If 'Other' became 2x faster, what is the overall speedup? Check by counting cycles.
NEXT LECTURE
Lecture 7: Classification of Instruction Set Architectures
Unit 2 starts: stack, accumulator, register-memory and load-store machines, and C = A + B in each.