https://github.com/ocramnaig94/parallel-all-pairs-shortest-path
A cost-optimal parallel algorithm based on Floyd-Warshall Algorithm in order to resolve the APSP problem
https://github.com/ocramnaig94/parallel-all-pairs-shortest-path
all-shortest-path apsp c floyd-warshall-algorithm mpi mpich parallel-programming
Last synced: 8 months ago
JSON representation
A cost-optimal parallel algorithm based on Floyd-Warshall Algorithm in order to resolve the APSP problem
- Host: GitHub
- URL: https://github.com/ocramnaig94/parallel-all-pairs-shortest-path
- Owner: Ocramnaig94
- License: gpl-3.0
- Created: 2024-06-02T13:23:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-12T20:32:49.000Z (over 1 year ago)
- Last Synced: 2025-01-15T11:12:21.938Z (10 months ago)
- Topics: all-shortest-path, apsp, c, floyd-warshall-algorithm, mpi, mpich, parallel-programming
- Language: C
- Homepage:
- Size: 1.79 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parallel All-Pairs Shortest Path (APSP) algorithm
A cost-optimal parallel algorithm based on Floyd-Warshall Algorithm in order to resolve the APSP problem
The sequential version of the Floydβs algorithm takes in input the adjacency matrix of size π Γ π, whose entries (π, π) represent the positive weights that refer to the distance between vertex π and vertex π, for π, π = 1, ... , π. The same matrix in output will contain the updated weights representing the shortest paths for each pair of nodes. The development of the parallel version was done according to Fosterβs PCAM methodology.
## Prerequisites
Install [MPICH](https://www.mpich.org/), a high performance implementation of the Message Passing Interface (MPI) standard.
Build the executables by using `Makefile`
```
make all
```
## How to Run
* Generate first the input square matrix through `gen_adj_matrix`, by providing the number or rows/columns and the name of the binary output file `.bin`. Optionally, a user-defined maximum weight can be set instead of the default one
```
./gen_adj_matrix optional:
```
* Alternatively, as the input square matrix a predefined one inside the homonymous folder `matrices` can be used.
* Run the APSP algorithm by providing the number of processors, which must be a [perfect square](https://en.wikipedia.org/wiki/Square_number), and the binary file containing the adjacency matrix
```
mpiexec -n ./allshortestpair
```
## Benchmark
The benchmark was performed on a virtual machine on a single CPU machine with 4 physical cores, and 8 logical ones due to hyper-threading.
| Matrix size | Time on 1 processor | Time on 4 processors | Speedup | Efficiency |
| ----- | :---: | :---: | :---: | :---: |
| 1000 Γ 1000 | 1,7 seconds | 0,55 seconds | 3 | 0,75 |
| 3000 Γ 3000 | 38 seconds | 12 seconds | 3,16 | 0,79 |
| 5000 Γ 5000 | 174 seconds | 55 seconds | 3,16 | 0,79 |