English
Models, metrics, and scaling laws
Parallelism models
The way work is divided determines the parallelism model (Table 1.1).
Table 1.1. Parallelism models
| Model | Description | In this course |
|---|---|---|
| Data parallelism (data parallelism) | the same operation on different parts of a large dataset | Topics 6, 7, 10, 11 |
| Task parallelism (task parallelism) | different independent tasks run simultaneously | Topics 5, 10 |
| Pipeline (pipeline) | data passes through successive stages, each running in its own thread | Topics 4, 15 |
| Master–worker (master–worker) | the main process distributes pieces of work to workers and collects the results | Topics 2, 12, 13 |
| Message passing (message passing) | processes without shared memory communicate only through messages | Topics 12, 14–16 |
Choose a model based on the problem: image processing naturally divides the data into parts, a web server handles independent requests as tasks, and a pipeline is a convenient way to describe event-stream processing.
Parallel program metrics
Let
- speedup (speed-up)
— how many times faster the parallel program is than the sequential one; - efficiency (efficiency)
— the fraction of each processor’s capacity used; - cost (cost)
— total processor time; with ideal parallelization, it equals .
Ideal, linear speedup
For example, if
Amdahl’s law
Suppose a fraction
This gives the speedup under Amdahl’s law (Amdahl’s law, 1967):
As
If the parallel part accounts for 95%, the program can never become more than 20 times faster, regardless of the number of processors; at
Figure 1.6. Speedup under Amdahl’s law for different parallel fractions
Conclusions from Amdahl’s law:
- first reduce the sequential fraction of the program, then add processors;
- each doubling of the processor count provides a smaller gain;
- the law ignores overhead, so actual speedup is even lower: with too many threads, execution time can even increase.
The Gustafson–Barsis law and scalability
Amdahl’s law considers a fixed-size problem. In 1988, John Gustafson (John Gustafson) and Edwin Barsis (Edwin Barsis) pointed out that more processors are usually used to solve a larger problem: a finer weather-forecasting grid, more pixels, or more particles. The sequential part (reading parameters, collecting the result) grows only slightly.
Let
At
The two laws do not contradict each other; they correspond to two ways of evaluating a program’s scalability (scalability) (Fig. 1.7):
- strong scaling (strong scaling) — the problem size stays fixed while the processor count increases; the goal is to reduce execution time (Amdahl’s law);
- weak scaling (weak scaling) — the problem size grows in proportion to the processor count; the goal is to keep execution time constant (Gustafson’s law).
Figure 1.7. Strong and weak scaling
The Karp–Flatt metric
Measured speedup can estimate the fraction of a program that effectively behaves sequentially. The experimentally determined serial fraction (experimentally determined serial fraction), or Karp–Flatt metric (Karp–Flatt metric, 1990), is:
If