In this project, we implemented a parallel matrix inversion algorithm using OpenMP and MPI as part of the High-Performance Computing course at the University of Trento.
To run this project, ensure the following packages and tools are installed:
- C Compiler:
gccormpiccwith support for C99 or later. - MPI Library:
OpenMPI. - Python: Python 3.x for Jupyter Notebook.
Ubuntu/Debian:
sudo apt update
sudo apt install build-essential libopenmpi-dev python3 python3-pipFedora:
sudo dnf install gcc openmpi openmpi-devel python3 python3-pipArch Linux:
sudo pacman -S gcc openmpi python python-pipThe Jupyter Notebook (matrix_generator.ipynb) requires the following Python packages:
numpymatplotlibjupyter
Install them using pip:
pip install numpy matplotlib jupyterThis project includes three implementations of the matrix inversion algorithm:
-
OpenMP Implementation
- Main File:
main.c - Utilizes OpenMP for parallel computation.
- Main File:
-
MPI Implementation
- Main File:
mpi_inverse_main.c - Leverages MPI for distributed-memory parallelism.
- Main File:
-
Serial Implementation
- Main File:
main_serial.c - Provides a baseline for performance comparison.
- Main File:
-
OpenMP Execution (Main File:
main.c)mpicc -std=c99 -g -Wall -I./helpers -o main_program ./helpers/common.c ./helpers/file_reader.c matrix_inversion_parallel.c matrix_inversion.c main.c -lm
-
MPI Execution (Main File:
mpi_inverse_main.c)mpicc -std=c99 -g -Wall -I./helpers -o main_program ./helpers/common.c ./helpers/file_reader.c matrix_inversion_parallel.c matrix_inversion.c mpi_inverse_main.c -lm
-
Serial Execution (Main File:
main_serial.c)mpicc -std=c99 -g -Wall -fopenmp -I./helpers -o main_program ./helpers/common.c ./helpers/file_reader.c matrix_inversion_parallel.c matrix_inversion.c main_serial.c -lm -pg
The matrix_inversion.sh script is configured with different values for ncpus as needed. To submit the script to a cluster, use:
qsub matrix_inversion.shThis command returns a task ID. The resulting output and errors can be found in:
matrix_inversion.sh.o[task_id]matrix_inversion.sh.e[task_id]
- Copy paste the logs and rename them based on the naming specified in the jupiter notebook
- Matrix Generator: Use the
matrix_generator.ipynbnotebook to generate test matrices. - Performance Metrics: Metrics are automatically saved in the
Metricsfolder after code execution.
- Source Files:
main.c: OpenMP implementation.mpi_inverse_main.c: MPI implementation.main_serial.c: Serial implementation.helpers/: Contains utility files (common.c,file_reader.c).
- Jupyter Notebook:
matrix_generator.ipynbfor generating test matrices. - Metrics Folder: Stores performance metrics.
- Shell Script:
matrix_inversion.shfor submitting cluster jobs.
This project is licensed under the MIT License. See the LICENSE file for details.