Measuring strong/weak scaling, profiling, benchmarking
After this lecture you can
Million lattice updates per second vs. MPI processes for LBM implementations; Greiner & Pastewka, Proceedings of the bwHPC Symposium (2019).
This is the kind of plot you will produce – intuition alone is not reliable, you must measure.
Fixed problem size, increase number of processes \(p\):
\[S(p) = \frac{T_1}{T_p}, \qquad E(p) = \frac{S(p)}{p}\]
Deriving Amdahl’s law. Split the serial runtime \(T_1\) into a part that cannot be parallelized and a part that can:
\[T_1 = \underbrace{f_s\,T_1}_{\text{serial}} + \underbrace{(1-f_s)\,T_1}_{\text{parallelizable}}\]
On \(p\) processes the parallel part shrinks by \(p\), the serial part is unchanged:
\[T_p = f_s\,T_1 + \frac{(1-f_s)\,T_1}{p} \;\Rightarrow\; S(p) = \frac{T_1}{T_p} = \frac{1}{f_s + \dfrac{1-f_s}{p}} \;\xrightarrow{p\to\infty}\; \frac{1}{f_s}\]
Amdahl’s law: a serial fraction \(f_s\) caps the speedup at \(S_\max = 1/f_s\).
Even 1% serial code limits you to \(100\times\) – and communication overhead bites earlier.
Strong-scaling efficiency \(E = S/p\) under Amdahl’s law: efficiency decays even before the speedup visibly saturates.
Report efficiency alongside speedup – it exposes waste that log-log speedup plots hide.
Fixed work per process, increase \(p\) to solve a larger problem:
\[E(p) = \frac{T_1}{T_p} \qquad \text{(ideal: flat line at } 100\%\text{)}\]
Deriving Gustafson’s law. Measure the scaled workload on \(p\) processes and normalize its runtime to \(T_p = 1\). Split it into a serial and a parallel part:
\[T_p = f_s' + (1-f_s') = 1\]
Re-running this same work on a single process leaves the serial part unchanged but expands the parallel part \(p\)-fold:
\[T_1 = f_s' + p\,(1-f_s') \;\Rightarrow\; S(p) = \frac{T_1}{T_p} = f_s' + p\,(1-f_s') = p - f_s'\,(p-1)\]
\[\text{MLUPS} = \frac{N_x \cdot N_y \cdot \text{timesteps}}{\text{wall time} \cdot 10^6}\]
Four regimes: ideal (\(S = p\)) → super-linear (local problem fits in cache) → Amdahl plateau (serial fraction) → rollover (communication overhead dominates).
A profiler answers: where does the time go on one rank? (A scaling run answers: does the whole code scale.)
Compile with -fno-omit-frame-pointer for accurate call stacks.
Key metrics: cache-misses, branch-misses, topdown-mem-bound.
Kernel profiling answers: is each GPU kernel using the hardware well?
NVIDIA: ncu (Nsight Compute) per kernel, nsys (Nsight Systems) for the timeline
AMD: rocprof
Key metrics: occupancy, memory throughput, achieved vs. peak bandwidth.
A microbenchmark answers: how fast is this one function – and does a change make it faster?
HPC: Parallelization on GPUs and Accelerators