S4 · Lesson 2 · Amdahl's and Gustafson's laws
The limits of speeding up part of a job, scaled workloads, and sizing multicore chips
Speed up part of a job and the rest becomes the bottleneck. That plain observation, made precise by Gene Amdahl in 1967, is the most-used equation in computer architecture. It says a program that's 90% parallel can never run more than 10 times faster, however many processors it gets. Gustafson's law answers back: people don't use bigger machines to run the same job faster, they run bigger jobs in the same time, and then the serial part shrinks in proportion. Between them they frame every decision about multicore chips, accelerators and where to spend design effort.
- Speedup against the number of processors N, on a log scale, for a program whose parallel fraction is p.
- Solid: Amdahl's fixed-size speedup, , which flattens at . Dashed: Gustafson's scaled speedup, , which keeps growing because the problem grows with the machine.
- Slide p from 0.9 to 0.99: the Amdahl limit goes from 10 to 100. The last few percent of serial code decide everything.
Predict
A program spends 90% of its time in code that parallelizes perfectly. How fast can it get on 1000 processors?
9.9 times. The 10% serial part still takes its full time, so even if the parallel 90% took no time at all the speedup would be 1/0.1 = 10. On 16 processors it's already 6.4. To use 1000 processors well, the serial fraction has to be a small fraction of a percent, or the job has to grow with the machine.
Name it
Amdahl's law
If an enhancement speeds up a fraction F of the execution time by a factor S, the overall speedup is
Several enhancements on disjoint fractions: . The lesson for design: make the common case fast, and know what fraction of time it really is.
Gustafson's law
If the parallel part grows with N while the serial time stays fixed, and p is the parallel fraction measured on the N-processor run, the scaled speedup is
Weather models, simulations and training runs behave this way: a bigger machine buys a finer grid or a bigger model.
Sizing multicore chips (Hill and Marty)
A chip has n units of area (base core equivalents). A core built from r units runs times faster than a 1-unit core (a common rule of thumb, Pollack's rule). A symmetric chip of such cores runs the serial part on one core and the parallel part on all of them:
Small cores lose on the serial part, big cores on the parallel part; the best r sits in between.
Worked example
A program is 90% parallel. Find its speedup on 16 and 1000 processors, and the parallel fraction needed for a speedup of 10 on 16.
Show the solution
- 16 processors.
- 1000 processors.
- Fraction for a speedup of 10 on 16. Solve for F:
- Gustafson's view. The same 16-processor run with p = 0.9 gives a scaled speedup of
Answer a speedup of 6.4 on 16 processors and 9.9 on 1000; a speedup of 10 on 16 needs F = 0.96 (Gustafson's scaled speedup for the 16-processor run is 14.5).
Worked example
A chip has 256 base-core units and runs code that's 97.5% parallel. Compare symmetric designs with cores of 1, 4, 16 and 64 units.
Show the solution
- r = 1 (256 small cores).
- Bigger cores. With 64 cores each 2× faster (r = 4), 16 cores 4× faster (r = 16) and 4 cores 8× faster (r = 64):
- Best r. Scanning every r, the best is r = 7, at 51.2.
- What tiny cores cost. A chip of only tiny cores loses almost a third of the possible speedup to the 2.5% serial code.
Answer speedups of 34.7, 49.7, 46.5 and 29.8 for r = 1, 4, 16 and 64; the best symmetric design is r = 7, at 51.2.
Worked example
Two enhancements speed up disjoint parts of a program: 30% of the time runs 10 times faster and 20% runs 3 times faster. What is the overall speedup?
Show the solution
- Untouched fraction. The two enhancements cover 30% + 20% = 50% of the time, leaving 0.5 untouched.
- Overall speedup.
- The cap. The untouched half caps the speedup at 2 whatever the enhancements do, so the bigger win would come from touching more of the time.
Answer the overall speedup is 1.68.
Check
An enhancement speeds up 0.7 of a program's time by 2×. What's the overall speedup?
Check
A fraction 0.95 of a program can be sped up without limit. What's the most the whole program can speed up?
Check
What parallel fraction does a program need to reach a speedup of 8 on 16 processors?
Check
On 128 processors, a scaled run is 0.8 parallel. What's its Gustafson speedup?
Check
A symmetric chip of 64 base units uses cores of 16 units each, with performance . What's its speedup on code that's 0.9 parallel?
Check
One enhancement speeds up 0.3 of the time by 4×, another speeds up a separate 0.25 by 3×. What's the overall speedup?
Check
An enhancement speeds up a fraction 0.8 of a program's time by 4. Separately, a scaled workload runs on 64 processors with parallel fraction 0.99.
(a)
What is the enhancement's overall speedup?
(b)
What is its limit as S grows?
(c)
What scaled speedup does Gustafson's law give?
Check
A fraction F of a program's time can be sped up by S.
Step 1
What overall speedup results?
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°.
Step 2
What S would an overall speedup of T need (when T is below the limit)?
Step 3
What is the most any S can give?
Explain why
Why does Amdahl's law argue for building at least one big, fast core, even on a chip meant for parallel work?
Every parallel program has some serial part, and on a chip with many cores that part runs on one core while the rest wait. As the number of cores grows, the parallel part's time shrinks toward zero and the serial part's time, set by how fast a single core is, comes to dominate. A chip of only small, slow cores therefore caps its own speedup at a low level. Spending some of the area on a larger core speeds up exactly the part that limits everything else, at the cost of a few small cores whose loss barely matters once the parallel part is already fast. The best chips balance the two, or mix one big core with many small ones.
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.