↓Skip to main content

Social force modelling

Description #

Project for Advanced Systems Lab, where the goal is to make one algorithm run as fast as possible on a single core. Ours was the social force model, which simulates pedestrian crowds by treating each person as a particle driven by attractive and repulsive “social” forces from their destination, from other pedestrians and from obstacles.

In a team of four we started from a straightforward baseline implementation and worked through successive optimisation rounds:

  • Cost analysis: Counting flops and establishing a roofline to know what the achievable ceiling actually was.
  • Scalar optimisation: Strength reduction on the force kernels, hoisting and precomputing invariants, replacing transcendental calls with cheaper approximations.
  • Memory layout: Moving from array-of-structs to struct-of-arrays and blocking the interaction loop so the working set stays in cache.
  • Vectorisation: Hand-written AVX intrinsics for the inner loops, with the data layout reshaped so loads stay aligned and contiguous.
  • Algorithmic tweaks: We also found that an approximation algorithm can increase throughput at the cost of precision, which we analysed separately.

Different versions were benchmarked against the baseline across a range of crowd sizes.


(Source code not provided due to university policy)