This is my solution to an homework done at the PARALLEL PROGRAMMING course at Politecnico di Milano in 2022.
The prompt was to build a parallel version of the grep
program using MPI.
The homework prompt is aviable in Grep_Homework_Question notebook while my solution is in theGrep_Homework_Solution notebook.
You can open the solution directly on colab:
This homework is in C++ so you need a development envirorment that supports it, if you need help I found this good guide.
You also need to install MPI.
To run the notebooks you need to have Python installed.
To compile use:
mpicxx -fdiagnostics-color=always -g src/grep-main.cpp src/grep.cpp -o dest/grep-mpi.exe
mpicxx -fdiagnostics-color=always -g src/grep-sequential.cpp -o dest/grep-sequential.exe
And to run:
mpiexec -np 1 dest/grep-sequential matter input_file.txt
mpiexec -np 8 dest/grep-mpi matter input_file.txt
The following files and folder are present:
- Grep_Homework_Question.ipynb: contains the homework prompt.
- Grep_Homework_Solution.ipynb: contains my solution.
- input_file.txt: The input file to test the program
- src/: Folder containing
cpp
source files.- grep-sequential.cpp: A sequential implementation of grep which also measures the enlapsed time.
- grep-main.cpp: The
main
function of the parallel implementation. - grep.cpp: The implementation
grep-mpi
helper functions the parallel implementation. - grep.h: The header file of
grep-mpi
helper functions the parallel implementation.
- outputs/: Folder which will contain the outputs.
- output-correct.txt: The correct output of the normal
grep
.
- output-correct.txt: The correct output of the normal
- dest/: Folder which will contain the compiled executable files.
- .vscode/: Folder containing some VS Code configurations.