In this project, several C implementations are provided to parallelize the n-body problem.
Two approaches were followed to work on the project:
- direct sum algorithm (exhaustive)
- Barnes-Hut algorithm.
A single process version and two multicore versions are provided for both algorithms:
- one with distributed memory (implemented using the MPI library)
- one with shared memory (implemented using the OMP library).
In this repository you will find:
- Various versions of the code are provided that analyze the optimization process.
- A detailed report is provided explaining the various codes and the reasons for the choices made.
- Python scripts are present in the utility folder for:
- carry out performance tests
- generate input files with random bodies
- render the output file and have a graph of the bodies
- test the similarity between the outputs of the different implementations
- a data folder with some pre-populated input csv files end some expected output
To run the codes correctly you need to install the libraries:
- open-mpi
- omp
- mathplot (for render)
To download the sources clone this repository.
there is a makefile for each subfolder that compiles the various versions. Just set the current working directory to the folder of the file you want to run and run make
.
- exhaustive sequential version
.\<name_of_executable> <input_file> <simulation_steps>
- Barnes Hut sequential version
.\<name_of_executable> <input_file> <simulation_steps> <approx_threshold>
- exhaustive mpi version
mpirun -n <number_of_cores> <name_of_executable> <input_file> <simulation_steps>
- Barnes Hut mpi version
mpirun -n <number_of_cores> <name_of_executable> <input_file> <simulation_steps> <approx_threshold>
- exhaustive omp version
.\<name_of_executable> <input_file> <simulation_steps> <thread_count>
- Barnes Hut omp
.\<name_of_executable> <input_file> <simulation_steps> <approx_threshold> <thread_count>
The output file will be written to the current directory with the name output.csv