An open API service indexing awesome lists of open source software.

https://github.com/fraadap/n-body-parallelization

💻 N-Body problem parallelization with OpenMP and MPI
https://github.com/fraadap/n-body-parallelization

c mpi multicore multithreading nbody-problem nbody-simulation openmp

Last synced: 4 months ago
JSON representation

💻 N-Body problem parallelization with OpenMP and MPI

Awesome Lists containing this project

README

          

# N-Body Problem Parallelization
This project contains several C implementations capable of parallelizing the [n-body problem](https://en.wikipedia.org/wiki/N-body_problem). The project was made by students for a Multicore Programming course within a BSc degree program in Computer Science.

## ♟️ Algorithms
Two algorithms were used to experiment:
- A trivial direct sum algorithm with time complexity: $O(n^3)$
- The [Barnes-Hut algorithm](https://en.wikipedia.org/wiki/Barnes%E2%80%93Hut_simulation) with time complexity: $O(n \log n)$

Both algorithms have been parallelized and compared.

## 👾 Implementations
A single process version and two multicore versions are provided for both algorithms:
- One with distributed memory, implemented using the [MPI](https://en.wikipedia.org/wiki/Message_Passing_Interface) library.
- One with shared memory, implemented using the [OpenMP](https://en.wikipedia.org/wiki/OpenMP) library.

## 🗂️ In this repository
In this repository you will find:
- Various versions of optimization procedures done on the initial code.
- A detailed report explaining the various optimizations and the reason behind the choices made.
- Some utility Python scripts that are able to:
- 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
- The data used for performance analysis, including pre-populated input csv files end some expected results.

## 📚 Libs
To run the codes correctly you need to install the libraries:
- open-mpi (C)
- omp (C)
- mathplot (Python, only to render the results)

## 💻 Usage
First, clone [this repository](https://github.com/Exyss/n-body-parallelization.git). In each subfolder there is a makefile that automatically compiles the associated version. Set the current working directory to the desired folder and run `make`.

### To run the code:
- **exhaustive sequential** version

```bash
.\
```
- **Barnes Hut sequential** version
```bash
.\
```
- **exhaustive mpi** version
```bash
mpirun -n
```
- **Barnes Hut mpi** version
```bash
mpirun -n
```
- **exhaustive omp** version
```bash
.\
```
- **Barnes Hut omp**
```bash
.\
```

The output file will be written to the current directory with the name _output.csv_