CPSC 521 assignment 1

Back to assignment list.

Assignment description

This program performs an n-body physics simulation with one body per process. The code is parallelized with MPI, using only basic MPI functions like MPI_Send and MPI_Recv.

Assignment tweaks

This assignment has several macros that can be changed at the top of the source code to alter its behaviour. Some of them are:

There is also SERIALIZE_VELOCITIES, if you want the program to have larger messages being sent.

It turns out that the ring communication is much more efficient than broadcast communication: in a typical case of 8 processes and 8 bodies and 1000000 rounds, ring takes 4.799 and broadcast takes 9.081 seconds. Clearly, using a ring instead of my initial first-intuition scheme is a better idea.

Using floats is actually slower than doubles (doubles take 4.799 and floats take 5.262 seconds in the same case as above) on the given hardware setup. This is only based on one test case and results may vary for different scenarios.

Finally: both this assignment and the next calculate velocities and positions alternately, staggering them so that the new values can be used (i.e. backward Euler, not forward). This results in a system that should conserve energy better.


Page generated on Mon Jan 25 05:18:50 2021