The second part of the Performance Programming module (EPCC11009), was to
manually optimise a C-based molecular dynamics simulation code. The project
required the transformation of a suboptimal legacy codebase into a
high-performance solution, prioritising runtime reduction without compromising
the integrity of the simulation results. A key restriction imposed by the
project was that all optimisations must be done using a single thread i.e no
multi-threading.
We were provided with two codes which implement the same algorithm in two
different ways. The algorithm is an adaptive quadrature method that computes the
integral of a function on a closed interval using a divide-and-conquer method.
The algorithm starts by applying two quadrature rules (3-point and 5-point
Simpson’s rules) to the whole interval. If the difference between the integral
estimates from the two rules is small enough (or the interval is too short), the
result in added to the total integral estimate. If it is not small enough, the
interval is split into two equal halves, and the method is applied recursively
to each half. In the case supplied, evaluating the function requires the
solution of an ODE (ordinary differential equation) which is relatively
expensive in time.