N-Body Simulation parallelized with Open MP and OpenCL

Jonas Jaszkowic and Richard Remus

Building

You need CMake and Make to build the project. Also you have to have OpenCL installed and g++-6 should be available at /usr/bin/g++-6, otherwise you should update CMakeLists.txt to your needs.

For example you can build like this:

    mkdir build
    cd build
    cmake .. && make

GTest sources will be pulled automatically.

If anything goes wrong and you find that you have to change the CMakeLists.txtor your environment, do not forget to clean everything that was generated by CMake and Make, i.e. clean the build directory.

The build was tested on MacOS Sierra and in Docker running Debian 9.0 "Stretch".

Running

The main executable is called nbody_psys17.

For example, you can run the app like this:

    ./nbody_psys17 ../resources/solar_system.txt -1 omp

The application provides hints on how to use its CLI, just give it a try.

You will have to give a configuration file containing the start positions of the bodies, two of those can be found in the resources folder:

  • solar_system.txt contains start configuration for our solar system
  • random_galaxy.txt contains a random configuration

You can also create new random configurations using the provided python script.

Visualizations

We provided two visualizations with Processing in the directories realtime_visualization and replay_visualization respectively.

You might also want to take a look at the bash scripts in these directories to run the visualization more comfortable. For the realtime visualization you might want to update the script with the path to the executable (default is cmake-build-debug/nbody_psys17 in project root).