You will be measuring the difference between Array of Structures and Structure of Array forms for a simple fluid simulation.

Base code

Find some sample code for a simple Smoothed Particle Hydrodynamics simulation here. You will need to port this code to the platform, compiler and language that you are using for this class and add timing calls to measure the performance. Note that this code is missing a bunch of what you'd need for a real fluid simulation (see this page for a summary of what is missing). Also, I've done no testing to see if the numbers I've chosen for stiffness, base density, gravity, and particle radius are actually stable. None the less, it creates a couple hundred thousand particles and includes separate passes over those particles to build a neighbor-finding data structure, compute local density and pressure, compute forces from pressure and gravity, and update velocities and positions.

Modified code

Produce a new version of this program using the Structure of Arrays form instead of the provided Array of Structure form.


Changed: Measure the timing for both SoA and AoS code, and report how long it takes to simulate one step of 1,000,000 particles with the particle radius and baseDensity of 0.005. It is only necessary to do the timing for the first step, not for subsequent steps (which take considerably longer than the first one).

691 students

Graduate students have the option to find another small code sample to convert instead of this fluid code. This can be code you have already or code you find online. If you choose to do this, I recommend choosing something related to your research area. Ideally, it should be something making several passes over at least a few thousand elements, where each pass uses only some of the data.


Edit "assn2/README.txt" to describe your test computer (at least OS and CPU), what language and compiler you used, and how to build and run your project. Also include your timing data and particle numbers. For 691 students, your README should also tell me about your second code, where it came from, what it does, and what performance changes you saw from reorganizing the code.