English
Numerical methods and performance prediction
Parallel solution of nonlinear equations
The roots of an equation
- root isolation: the segment is divided into
small segments, and those at whose endpoints has different signs are found; each such segment contains a root; - refinement of each root by bisection, the secant (chord) method, or Newton’s method.
Both stages are perfectly parallel: the values of
Bisection halves the segment at each iteration and keeps the half with a sign change; after
Newton’s method
The conjugate gradient method
For large sparse systems
, , ;- for
: ; ; ; ; - if
, stop; otherwise, , .
One iteration contains one matrix–vector multiplication, two dot products, and three axpy operations (axpy operations are fully parallel, and the dot products are reductions. It is the reductions that limit scalability: each requires global synchronization (MPI_Allreduce on a cluster, Topic 12), and the iteration cannot proceed until the number
Determinism is especially important in iterative methods: if the dot products depend on the order in which threads finish, the number of iterations can change from run to run. In the lab (Example 2), the conjugate gradient method for the pentadiagonal matrix of the Poisson equation on a
Systems of ordinary differential equations
The initial value problem for a system
The error over the interval is
Time steps are sequential:
- parallelism across trajectories (parametric computations, parameter sweep): the system is solved for thousands of parameter sets or initial conditions, and each trajectory is independent. This is the simplest and most efficient case, but trajectories have different durations (one stops in a second, another in a minute), so dynamic load balancing is needed. On a cluster and in a grid, each group of trajectories becomes a separate job (Slurm job arrays, Topic 13);
- parallelism across components: for a large system (the method of lines for the heat equation, an
-body problem with millions of particles), the computation of is divided among threads by the components of . Synchronization is needed between the stages (four barriers per step), so there must be enough components for the work of a stage to outweigh a barrier; - parallelism in time (the Parareal algorithm and similar ones): a coarse sequential solution is refined in parallel on time intervals; it is used on very large clusters when the other dimensions are exhausted.
In the lab (Example 3), 3072 trajectories of a damped pendulum for different damping coefficients and initial velocities take from a few to hundreds of milliseconds. The block distribution gave a speedup of only 2.3, the cyclic one 11.0, and the dynamic one with a shared counter 11.9 on 16 logical processors.
Analytical performance prediction
Amdahl’s and Gustafson’s laws (Topic 1) estimate the speedup from the fraction of sequential code. For a specific algorithm, a more accurate prediction is given by an execution time model built from the PCAM stages:
where
Example: matrix–vector multiplication. For horizontal stripes in shared memory,
where double matrix, Parallel.For (a few microseconds). For vertical stripes and the checkerboard scheme, a reduction of the partial vectors and one more parallel loop are added. For
Example: matrix multiplication. In the lab, the prediction
Screenshot
Windows Terminal: dotnet run -c Release of the lab example 1 project (MatMul); the table Scheme / p / Time, ms / S / Predicted S / E / max|ΔC| for stripes, checkerboard, Cannon
Figure 8.11. Predicted and measured speedup
Isoefficiency
Efficiency can be expressed through the overhead
As
The dependence
Table 8.6. Isoefficiency functions of typical algorithms
| Algorithm (distributed memory) | Overhead | Isoefficiency |
|---|---|---|
| tree sum of | ||
| matrix–vector, stripes | ||
| matrix–vector, checkerboard | ||
| Cannon’s matrix multiplication |
For example, for the sum of