This project consists in a simplified implementation of a string matching algorithm, with the introduction of parallel computation through the use of Microsoft MPI APIs.
The main files that build up the project are:
- grep.h: class that defines the grep namespaces, which includes data types and functiions that are useful for the implementation of the algorithm.
- grep-main.cpp: the entry point fo the program, which implements the string matching algorithm, with the management of multiple processes.
The code is entirely written in C++ programming language, with the use of the following libraries and APIs (omitting the standard ones):
- fstream: used for parsing the text file
- cstring: used for copying the content of vectors of strings into an unique array of chars, that is necessary as a consistent input for MPI functions
- mpi.h: which introduces parallel computation in the algorithm, through a message passing mechanism between processes.
Check the analysis of the performances of the implementation here
mkdir build
cd build
- Generate the makefiles
cmake -G “MinGW Makefiles” ..
- Build the project
cmake --build .
- Run the program
mpiexec -np <num_proc> .\parallel_grep.exe <word_to_search> ..\resources\input_file.txt
where <num_proc> needs to be replaced by a positive integer representing the number of processes that will execute the code, and <word_to_search> needs to be replaced by a string representing the word to be found