PX457 · Course contents

Measuring and Accelerating: Performance Metrics

A program is eight times faster on sixteen processors. Is that good? We need to know which serial baseline was used, whether the problem changed, and what the extra processors spent time doing. The earlier chapters supplied mechanisms of waiting; this chapter supplies definitions that distinguish their effects.

1. Define the experiment before the ratio

Let NN denote a stated problem-size parameter and P≥1P\ge1 the processor count. NN might mean matrix dimension, number of particles or number of quadrature points; the work need not grow linearly in NN:

CalculationRepresentative work scaling
Dense matrix diagonalisationO(N3)O(N^3)
FFTO(Nlog⁡N)O(N\log N)
Direct all-pairs N-body interactionsO(N2)O(N^2)
Composite trapezoidal rule with N pointsO(N)O(N)

Let T(N,P)T(N,P) be elapsed time for a defined workload and numerical accuracy. Use a meaningful one-processor baseline, the same timing boundaries and representative data. Include transfers or setup if the application pays them; if reporting kernel-only times, label them. Repeat measurements and report variability, compiler settings and resource placement.

For distributed timings, the job cannot finish before its slowest rank. Time local intervals with MPI_Wtime and reduce their durations using MPI_MAX; clocks need not be synchronised for local duration measurements. A barrier can align a timed phase but itself changes the experiment. For CUDA, asynchronous launches require completion-aware timing, as the next chapter explains.

The source's runtime model

Separate the one-processor work into serial and parallelisable parts:

T(N,1)=σ(N)+π(N),T(N,1)=\sigma(N)+\pi(N),

and model the parallel time as

T(N,P)=σ(N)+π(N)P+κ(N,P),κ(N,P)≥0,κ(N,1)=0.T(N,P)=\sigma(N)+\frac{\pi(N)}P+\kappa(N,P),\qquad \kappa(N,P)\ge0,\quad\kappa(N,1)=0.

κ\kappa is elapsed-time overhead: communication, scheduling, synchronisation, imperfect load balance and other departures from ideal division. This model assumes a fixed algorithm and baseline. Cache effects, different algorithms or changed frequency can violate its assumptions and can even produce apparent superlinear speedup. Those observations need explanation rather than being forced into a nonnegative-overhead model.

2. Speedup and efficiency answer different questions

Define

ψ(N,P)=T(N,1)T(N,P),ϵ(N,P)=ψ(N,P)P=T(N,1)P T(N,P).\psi(N,P)=\frac{T(N,1)}{T(N,P)},\qquad \epsilon(N,P)=\frac{\psi(N,P)}P =\frac{T(N,1)}{P\,T(N,P)}.

Speedup asks how much elapsed time was saved. Efficiency compares processor-time consumed with the baseline time. Eightfold speedup on sixteen processors has ϵ=1/2\epsilon=1/2. That may be worthwhile for a deadline even though it doubles processor-time cost.

Efficiency is not a hardware utilisation counter. A processor can be busy executing redundant work while algorithmic efficiency is poor; idle periods and overhead contribute to the same ratio.

3. Amdahl's bound follows from a floor on elapsed time

At fixed NN, define

F=σ(N)σ(N)+π(N)∈[0,1].F=\frac{\sigma(N)}{\sigma(N)+\pi(N)}\in[0,1].

Divide the runtime model by T(N,1)T(N,1):

T(N,P)T(N,1)=F+1−FP+κ(N,P)T(N,1).\frac{T(N,P)}{T(N,1)} =F+\frac{1-F}{P}+\frac{\kappa(N,P)}{T(N,1)}.

Since overhead is nonnegative,

ψ(N,P)≤1F+(1−F)/P,ϵ(N,P)≤1PF+1−F.\psi(N,P)\le\frac1{F+(1-F)/P},\qquad \epsilon(N,P)\le\frac1{PF+1-F}.

This is Amdahl's law under the model's assumptions. For F>0F>0, the speedup ceiling as P→∞P\to\infty is 1/F1/F. For F=0F=0, this bound has no finite ceiling, though overhead or finite available parallelism can still limit scaling. For P>1P>1, positive FF prevents unit efficiency; unit efficiency is possible in this ideal model only with both F=0F=0 and zero overhead. At P=1P=1, efficiency is one by definition.

Take F=0.1F=0.1 and zero overhead. On four processors, runtime relative to serial is 0.1+0.9/4=0.3250.1+0.9/4=0.325, speedup 40/13≈3.07740/13\approx3.077 and efficiency 10/13≈0.76910/13\approx0.769. On sixteen processors, speedup is 6.46.4 and efficiency 0.40.4. Even infinitely many processors cannot exceed tenfold speedup.

The serial part refuses to shrink
P=1P=4P=160.3250.1562501
Relative runtime for F = 0.1 with no overhead. Teal marks the serial 0.1; outlined segments mark parallel work divided by P. All three bars use the same scale. These are exact model predictions, not benchmark results. ↗

Instead of comparing just three processor counts, grow the machine continuously through the integer counts. Watch the part of the bar that refuses to shrink.

Add processors; watch the floor remain

Keep the problem fixed while the processor count grows. Which part can the extra workers actually shorten?

Play, pause, or scrub to inspect a moment.

1 processors · fixed problemT / T₁ = 1speedup = 101 (serial baseline)serial floor

Paused. P=1, F=0.1. Relative runtime 1, speedup 1, efficiency 1.

Processor count moves from 1 to 32, with zero overhead. Serial and parallel segments use one fixed scale. Relative time is F+(1−F)/P, so this is a bound model rather than a hardware forecast. ↗

4. Strong and weak scaling change different quantities

Strong scaling varies PP at fixed problem size and accuracy. Weak scaling grows the problem so that useful work per processor is approximately fixed. Good scaling is an experimental outcome, not part of either definition.

If work is proportional to NN, doubling NN when doubling PP maintains work per processor. If work is proportional to N2N^2, use N∝PN\propto\sqrt P instead. For a three-dimensional grid whose side length is NN, work proportional to N3N^3 gives N∝P1/3N\propto P^{1/3}. State whether NN denotes side length or total grid points.

The source's example growth laws σ∼N\sigma\sim N, π∼N2\pi\sim N^2 and κ∼Nlog⁡N+Nlog⁡P\kappa\sim N\log N+N\log P are illustrative algorithm models, not general HPC laws. They explain why the serial fraction and relative overhead can fall when problem size grows at fixed PP. Check memory capacity and algorithmic complexity before attributing better scaling to “larger N”.

The two scaling experiments hold different geometry fixed. Return to the square halo model and compare the local area with its boundary as the process grid grows.

Keep the global square, or keep each local square

As the process grid grows, watch the useful local area and the boundary that must be exchanged.

Play, pause, or scrub to inspect a moment.

milestone: N = 24; P = 1local sideℓ = 24 · halo/work ≈ 0.167

Paused. Strong scaling milestone 1×1: global side 24, local side 24. Geometry morphs to the next integer grid; intermediate frames are not fractional process counts.

A square process grid grows from 1×1 to 4×4. Strong scaling fixes the global side at 24; weak scaling fixes the local side at 24. Counts use width-one face halos, ignoring corners. Motion between integer grid milestones is a geometric transition, not a fractional process count. ↗

Isoefficiency asks how much growth is enough

Define processor-time overhead

TOH(N,P)=P T(N,P)−T(N,1).T_{\mathrm{OH}}(N,P)=P\,T(N,P)-T(N,1).

Then, exactly by definition,

ϵ(N,P)=T(N,1)T(N,1)+TOH(N,P).\epsilon(N,P)=\frac{T(N,1)}{T(N,1)+T_{\mathrm{OH}}(N,P)}.

This is an equality, correcting the source's inequality. In the additive runtime model,

TOH=(P−1)σ+Pκ.T_{\mathrm{OH}}=(P-1)\sigma+P\kappa.

Thus elapsed overhead κ\kappa and processor-time overhead are not the same object. To maintain a target 0<ϵ0<10<\epsilon_0<1, solve

T(N,1)=ϵ01−ϵ0TOH(N,P).T(N,1)=\frac{\epsilon_0}{1-\epsilon_0}T_{\mathrm{OH}}(N,P).

For example, suppose useful serial work is cNcN and elapsed overhead is alog⁡2Pa\log_2P, with no serial section. Then TOH=aPlog⁡2PT_{\mathrm{OH}}=aP\log_2P, so constant efficiency requires NN proportional to Plog⁡PP\log P. This is the isoefficiency relation. It grows faster than the N∝PN\propto P choice of ordinary weak scaling: constant work per processor does not guarantee constant efficiency.

5. Karp–Flatt measures an effective fraction

For P>1P>1 and positive measured speedup, invert Amdahl's expression:

FKF(P)=1/ψ(N,P)−1/P1−1/P.F_{\mathrm{KF}}(P)= \frac{1/\psi(N,P)-1/P}{1-1/P}.

Under the source's additive model, substitution gives a more revealing identity:

FKF(P)=F+κ(N,P)T(N,1)(1−1/P).F_{\mathrm{KF}}(P) =F+\frac{\kappa(N,P)}{T(N,1)(1-1/P)}.

The metric includes overhead. It does not directly measure a region of serial source code. For F=0.1F=0.1 and no overhead it returns 0.10.1 at both four and sixteen processors. If at four processors κ/T(N,1)=0.075\kappa/T(N,1)=0.075, runtime becomes 0.40.4 of serial, speedup is 2.52.5, and FKF=0.2F_{\mathrm{KF}}=0.2.

An increasing effective fraction is evidence consistent with growing relative overhead. A constant value is consistent with a fixed serial fraction, but can also hide overhead with suitable scaling. The ratio alone cannot uniquely distinguish causes; use profiles and communication/imbalance timings. Negative values can arise with superlinear speedups or baseline problems and signal assumptions to investigate. The metric is undefined at P=1P=1.

Exercises and course connection

  1. Derive the overhead identity and verify the F=0.1F=0.1 examples without a plot.
  2. Given measured T(N,1),T(N,2),T(N,4),T(N,8)T(N,1),T(N,2),T(N,4),T(N,8), report speedup, efficiency, variability and Karp–Flatt values. Avoid inferring a unique cause from those values alone.
  3. Design a weak-scaling experiment for an O(N2)O(N^2) algorithm. Explain why doubling both NN and PP changes work per processor.
  4. Relate terms in κ\kappa to OpenMP queueing, false sharing, MPI halo traffic and synchronisation. Which measurements would distinguish them?

The same discipline applies to accelerators: a kernel's peak arithmetic rate is insufficient if transfers and launch costs dominate. CUDA returns to the ownership and locality questions on GPU hardware.