Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Introduction to parallel computing

For decades, scientific codes got faster for free: each new generation of processors ran at a higher clock frequency. That free lunch is over. Today, performance gains come almost exclusively from parallelism, and scientific software has to be written to exploit many cores, many nodes, and accelerators.

In this lecture, we will:

Moore’s law

Statement of the law

Gordon Moore, a founder of Intel, stated in 1965 that:

The number of transistors that can be placed on an integrated circuit at a reasonable cost doubles every two years.

Data source: Wikipedia; figure from OurWorldInData.org, licensed under CC-BY by Hannah Ritchie and Max Roser.

Hardware evolution

Energy consumption and cost

Increasing the frequency is therefore no longer an option: the extra transistors are used to add more cores instead.

The memory wall

Von Neumann architecture

Programming instructions (stored-program) and data share the memory unit. They are loaded into the Central Processing Unit (CPU) for execution. Results are written back to the memory unit.

The Von Neumann bottleneck

Consequences and solutions

The Top500 list ranks the fastest computers in the world twice a year. It gives a nice view of how supercomputers have evolved.

Performance

Number of cores

Performance per core

The total performance keeps growing exponentially, but this growth is now driven by the number of cores, while the performance of each individual core has plateaued.

Parallel processing

Amdahl’s law

Gene Amdahl (1967) derived the theoretical maximum speedup obtained by ideally parallelizing a code, for a given problem with a fixed size:

Speedup(N)=TsTp(N)=1α+1−αN\text{Speedup}(N) = \frac{T_s}{T_p(N)} = \frac{1}{\alpha + \frac{1-\alpha}{N}}

where

In the limit of an infinite number of processors, the speedup saturates:

Speedup(N)→1αforN→+∞\text{Speedup}(N) \rightarrow \frac{1}{\alpha} \quad \text{for} \quad N \rightarrow +\infty

Strong scaling

Amdahl’s law describes strong scaling: the problem size is fixed, and we add more cores to solve it faster. The theoretical maximum speedup is:

Coresα\alpha = 00.01%0.1%1%2%5%10%25%50%
10109.999.919.178.476.905.263.081.82
10010099.091.050.233.616.89.173.881.98
100010009095009147.719.69.913.991.998
1000010000500090999.049.819.969.993.992
100000100000909199099.949.919.991042
∞\infty∞\infty10000100010050201042

Even with only 1% of non-parallel code, you can never go faster than 100 times the serial code, no matter how many cores you use. The right panel compares these curves to the ideal speedup (α=0\alpha = 0).

Gustafson’s law

John Gustafson and Edwin Barsis (1988) derived the theoretical maximum speedup obtained by ideally parallelizing a code for a problem of constant size per core:

Speedup(N)=Ts(N)Tp(N)=α+(1−α)N\text{Speedup}(N) = \frac{T_s(N)}{T_p(N)} = \alpha + (1-\alpha)N

Assuming that the execution time of the non-parallel part of the code remains constant, one has:

Ts(N)=αT0+N(1−α)T0T_s(N) = \alpha T_0 + N(1-\alpha)T_0
Tp(N)=αT0+(1−α)T0=T0T_p(N) = \alpha T_0 + (1-\alpha)T_0 = T_0

Weak scaling

Gustafson’s law describes weak scaling: the problem size grows with the number of cores. This law is more optimistic than Amdahl’s law:

Speedup(N)→(1−α)NforN→+∞\text{Speedup}(N) \rightarrow (1-\alpha)N \quad \text{for} \quad N \rightarrow +\infty

In both laws, everything is determined by α\alpha, the non-parallel fraction of the code. Reducing α\alpha is called “parallel code optimization”.

Hardware evolution

A Cray XC50 blade with GPUs.

Consequences

Communication network

Connecting millions of processors requires a high-performance network.

The fat-tree network is a non-blocking network topology invented by Charles Clos (1953). Depending on how many switches you can afford, you might choose blocking configurations instead.

See for example https://www.nvidia.com/en-us/networking/infiniband-configurator and http://clusterdesign.org/fat-trees/.

The key network parameters (switches and cables) are the latency and the bandwidth. For an InfiniBand network, the latency is 0.5-1 microsecond, and the bandwidth is 5-10 GB/s.

Parallel programming languages

Evolution of programming methods:

Distributed memory versus shared memory