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
- Host: GitHub
- URL: https://github.com/fraadap/n-body-parallelization
- Owner: fraadap
- License: mit
- Created: 2025-04-08T13:09:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-08T13:13:07.000Z (about 1 year ago)
- Last Synced: 2025-12-19T23:30:36.914Z (7 months ago)
- Topics: c, mpi, multicore, multithreading, nbody-problem, nbody-simulation, openmp
- Language: TeX
- Homepage:
- Size: 14.5 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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_