Parallelism and performance
Diperkenalkan
6:22
Arsitektur Komputer
This course looks at the machine below the program, and how it earns its speed. The first two units are the contract, the instruction set, and the machine that…
Narasi bahasa Inggris · takarir bahasa Inggris dan 中文 yang dapat dipilih
Dalam pelajaran ini
| English | Makna |
|---|---|
| Amdahl's law/ˈæmdɑːlz lɔː/ | the speed-up from parallel work is limited by the part that must run serially: 1/((1 − p) + p/n) |
| speedup/ˈspiːdʌp/ | |
| instruction-level parallelism/ɪnˈstrʌkʃn ˈlevl ˈpærəlelɪzəm/ | paralelisme tingkat instruksi |
| weak scaling/wiːk ˈskeɪlɪŋ/ | growing the problem size with the number of processors, keeping the work per processor fixed |
| strong scaling/strɒŋ ˈskeɪlɪŋ/ | keeping the problem size fixed while adding processors |
| Efficiency/ɪˈfɪʃənsi/ | The fraction of total energy or power input converted to useful output. |
| Load imbalance/ləʊd ɪmˈbæləns/ | Uneven division of work among parallel workers, so some sit idle while the slowest finishes. |
| Karp–Flatt metric/kɑːp flæt ˈmetrɪk/ | the serial fraction estimated from a measured speed-up, used to see why scaling falls short |
Amdahl's ceiling
- A program has a serial part and a parallel fraction $f$. On $p$ processors, Amdahl's law 阿姆达尔定律 gives $\text{Speedup} = 1/((1-f) + f/p)$. The serial part never shrinks, so as $p \to \infty$ the speedup can never pass $1/(1-f)$.
- With $f = 0.9$, at most $10\times$:
| Processors $p$ | Speedup |
|---|---|
| 2 | 1.82× |
| 4 | 3.08× |
| 8 | 4.71× |
| 16 | 6.40× |
| 64 | 8.77× |
| as many as you like | 10× |
- The second eight processors add $1.7\times$, where the first eight added $4.7\times$. With $f = 0.99$, reaching $50\times$ needs exactly $p = 99$.

With f = 0.9, the speedup ceiling is —
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
As p grows without bound, speedup tends to 1/(1 − f) = 10.
With a parallel fraction $f = 0.9$, enough processors can give a $12\times$ speedup.
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
As $p \to \infty$ the speedup tends to $1/(1 - f) = 1/0.1 = 10\times$. The serial $10\%$ never shrinks, so $12\times$ is impossible.
Price a speedup
- A render spends 36 s compositing (serial) and 64 s shading (parallel): $f = 0.64$. On 4 processors: $1/(0.36 + 0.16) = 1.92\times$, runtime $52.0$ s.
- On 8: $2.27\times$, $44.0$ s. The serial part now dominates, so the next thing to buy is a better algorithm, not a bigger machine.
- Report only measured speedups 加速比. The baseline is the same program on the same machine with one core active. Peak figures assume $f = 1$, which no program reaches.
36 s serial + 64 s parallel on p = 4 gives —
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
f = 0.64: 1/(0.36 + 0.16) = 1.92; runtime 100 × 0.52 = 52.0 s.
The parallelism ladder
- Before there were many cores, the pipeline was already instruction-level parallelism 指令级并行 (ILP): the 5-stage machine overlaps five instructions. Hardware threads (SMT) fill pipeline bubbles with another thread's work, and the hazard arithmetic still applies to each thread.
- ILP inside a core, threads on each core and cores on each chip form one ladder, and every step of it is limited by Amdahl's law.
The pipeline itself is a form of —
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
Five stages overlap five instructions — ILP within one core.
Strong and weak scaling
- Amdahl keeps the problem size fixed (strong scaling 强扩展). Gustafson grows the problem with the machine (weak scaling 弱扩展): if a run on $p$ processors spends a fraction $s$ on serial work, the scaled speedup is $s + (1 - s)p$. With $s = 0.1$ on $16$ processors: $0.1 + 0.9 \times 16 = 14.5\times$.
- Both are correct answers to different questions. Amdahl asks how much faster this job gets; Gustafson asks how much bigger a job fits in the same time. Synchronisation and communication add costs that neither formula counts, so always measure.
A program is 95% parallelizable. What is the largest possible speedup by Amdahl's law?
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
The ceiling is 1 / (1 - 0.95) = 1 / 0.05 = 20.
A run on 32 processors is 5% serial. What is the scaled (Gustafson) speedup?
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
0.05 + 0.95 x 32 = 0.05 + 30.4 = 30.45.
The slowest worker sets the time
- Four workers get tasks of 10, 10, 10 and 18 s. The job ends when the last one ends: 18 s, against an ideal of $48/4 = 12$ s.
- Efficiency 效率 is $48/(4 \times 18) = \mathbf{66.7\%}$. Load imbalance 负载不均衡 wastes cores that Amdahl's formula assumes are busy. Dynamic scheduling hands out small tasks so that no worker waits.
Tasks of 10, 10, 10 and 18 s on four workers: efficiency (one decimal, %)?
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
$48/(4 \times 18) = 0.667$.
Worked example: measure the serial fraction
- On 16 processors a job runs 6.4 times faster: efficiency $6.4/16 = 40\%$. The Karp–Flatt metric 卡普弗拉特度量 turns that into the serial fraction that is really there: $e = (1/S - 1/p)/(1 - 1/p)$.
- $e = (0.156 - 0.0625)/0.9375 = \mathbf{0.10}$, exactly Amdahl's $1 - f$ for $f = 0.9$. If $e$ grows with $p$, the overhead is growing too, and more processors will not help.
Speedup 6.4 on 16 processors: Karp–Flatt serial fraction (two decimals)?
Kesulitan 2/5 · 140 koin + bonus kecil pada penyelesaian pertama hari ini
$(1/6.4 - 1/16)/(1 - 1/16) = 0.09375/0.9375 = 0.10$.
A Karp–Flatt fraction that grows with $p$ means the program has no parallel overhead.
Kesulitan 1/5 · 100 koin + bonus kecil pada penyelesaian pertama hari ini
It means overhead such as communication grows with $p$.
Marks that slip away
- Expecting $p$ times faster on $p$ cores. With $f = 0.9$, $8$ cores give $4.71\times$, and no number of cores passes $10\times$.
- Taking a peak figure as a speedup 加速比. Measure against the same program on one core of the same machine; peak figures assume $f = 1$.
- Mixing up Amdahl and Gustafson. Amdahl fixes the problem size; Gustafson grows it with the machine. They answer different questions.
Recap
- Amdahl: speedup 加速比 $= 1/((1-f) + f/p)$, capped at $1/(1-f)$.
- $f = 0.9$: $4.71\times$ on 8 processors, $10\times$ at most.
- Gustafson's scaled speedup $s + (1-s)p$ grows with the problem.
Apa yang salah? Hanya tim situs yang dapat melihatnya.