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

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, 1(1−p)+p/N, which flattens at 11−p. Dashed: Gustafson's scaled speedup, N−(1−p)(N−1), 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?

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

speedup=1(1−F)+F/S≤11−F

Several enhancements on disjoint fractions: 1(1−∑Fi)+∑Fi/Si. 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

S=N−(1−p)(N−1)

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 r times faster than a 1-unit core (a common rule of thumb, Pollack's rule). A symmetric chip of n/r such cores runs the serial part on one core and the parallel part on all of them:

speedup=11−fr+frrn

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
  1. 16 processors. S=10.1+0.9/16=6.4
  2. 1000 processors. S=10.1+0.0009=9.9
  3. Fraction for a speedup of 10 on 16. Solve 1(1−F)+F/16=10 for F: F=1−1/101−1/16=0.96
  4. Gustafson's view. The same 16-processor run with p = 0.9 gives a scaled speedup of 16−0.1×15=14.5

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
  1. r = 1 (256 small cores). S=10.025+0.975/256=34.7
  2. Bigger cores. With 64 cores each 2× faster (r = 4), 16 cores 4× faster (r = 16) and 4 cores 8× faster (r = 64): r=4:49.7r=16:46.5r=64:29.8
  3. Best r. Scanning every r, the best is r = 7, at 51.2.
  4. 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
  1. Untouched fraction. The two enhancements cover 30% + 20% = 50% of the time, leaving 0.5 untouched.
  2. Overall speedup. S=10.5+0.3/10+0.2/3=10.5+0.03+0.067=1.68
  3. 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 r. 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°.

Explain why

Why does Amdahl's law argue for building at least one big, fast core, even on a chip meant for parallel work?

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.