159.735 - Assignment 1

To be submitted by 9th April 2009

This Assignment is concerned with using MPI to write a parallel N-Body simulation. The gravitational N-Body problem uses Newton's inverse square law to simulate the movement of a number of objects.

The force on an object depend on the gravitational attraction of every other object and can be calculated by:

Where Mi is the mass of body I, G is a gravitational constant and Di,j is the distance between body i and body j.

This force is then used to update the velocity of the objects and then move them.

There is a simple N-Body simulation at http://cs-alb-pc3.massey.ac.nz/notes/59735/n_body.c.

Your task is to rewrite this code so that it uses MPI and scales as well as possible. The program sets up 5000 bodies at random, then performs 10 iterations of the simulation and calculates a sum from the final positions. Your program should give the same sum but run on many processors. You must uses MPI to broadcast the positions, the initial random position should only be generated by one process.

Your program must be a single source file written in C or C++ and must run on the iimscluster.

Marks will be awarded for correct programs that perform as little communication as possible and run as fast as possible on many processors. The iimscluster machine has 8 processors but your code should also be able to run on larger machines.

This is an individual assignment, marks will be deducted for plagiarism and late submissions.

Programs that do not compile and run without modification will lose marks.

You should submit your program source code electronically from the paper web site.

M Johnson 2009