https://github.com/leonardogemin/parallelcomputing_unipd
Project for the course of Parallel Computing - University of Padua.
https://github.com/leonardogemin/parallelcomputing_unipd
c mpi parallel-computing
Last synced: about 1 year ago
JSON representation
Project for the course of Parallel Computing - University of Padua.
- Host: GitHub
- URL: https://github.com/leonardogemin/parallelcomputing_unipd
- Owner: leonardoGemin
- Created: 2023-07-27T20:30:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-21T06:39:59.000Z (over 2 years ago)
- Last Synced: 2024-01-26T07:39:48.141Z (about 2 years ago)
- Topics: c, mpi, parallel-computing
- Language: TeX
- Homepage:
- Size: 356 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Parallel Computing
MSc project experiences at UNIPD.
## Requirements
Install MPI: `sudo apt install libcr-dev mpich mpich-doc`
## Sequential version
Given two square matrices `A` and `B` of same size, `C` is compute as follows:
```
for (i = 0; i < SIZE; i++)
for (j = 0; j < SIZE; j++)
for (k = 0; k < SIZE; k++)
C[i][j] += A[i][k] * B[k][j]
```
* Compile with `gcc -o sequential -O3 sequential.c`
* Run with `./sequential [unlock verbose mode]`
## Parallel version
Given two square matrices `A` and `B` of same size, `C` is compute exploiting parallelization.
There are three variants of optimization:
1. Just the parallelization of the algorithm, called "mono"
2. "mono" + transposition of matrix `B` in order to read both `A` and `B` matrices row-wise order during the inner loop. This leads to less cache misses.
3. "mono" + changing of the order of the loops: from `i-j-k` to `k-i-j`. In this way `A[i][k]` is constant in the inner loop, while `B` and `C` are scanned in row-wise order.
* Compile with `mpicc -o parallel -O3 parallel.c`
* Run with `mpirun -np ./parallel [unlock verbose mode]`
## How to run on CAPRI server
Prepare a slurm file called `test.slurm` (just for example) like
```
#!/bin/bash
#SBATCH --job-name mmult
#SBATCH --output 2048_monokij_8.out
#SBATCH --error 2048_monokij_8.err
#SBATCH --mail-user leonardo.gemin@studenti.unipd.it
#SBATCH --mail-type ALL
#SBATCH --time 10:00
#SBATCH --ntasks 8
#SBATCH --partition allgroups
#SBATCH --mem 200M
mpicc -o parallel -O3 parallel.c
for ((i = 0; i < 10; i++)) do
mpirun -np 8 ./parallel 2048 2
done
```
and submit the job through `sbatch test.slurm`.
## Project report
Click [here](/report/main.pdf) to see the report of the project.
## Authors
* [Massimiliano Viola](https://github.com/massimilianoviola)
* [Leonardo Gemin](https://github.com/leonardoGemin)