Implementation of a master-slave hybrid parallel program (shared and distributed memory) to identify prime numbers in an array, utilizing Open MPI and OpenMP libraries (PAs 1 and 3 from Parallel Computing course - DCOMP - UFSJ).
-
GCC compiler:
sudo apt install gcc
-
OpenMP library:
sudo apt install libomp-dev
-
Open MPI library;
-
gprof tool;
-
To install all dependencies:
./install_dependencies.sh
-
Python3 and pip package manager:
sudo apt install python3 python3-pip build-essential python3-dev
-
PyCryptodome library:
pip install pycryptodomex
-
Matplotlib library:
pip install matplotlib
-
seaborn library:
pip install seaborn
Execute the following command to compile the source code:
make
You can alter the parameters, such as the instance file and number of processes in the Makefile. For distributed running, first you may need to gain remote acess to the machines in your network by generating a private key with the following commands:
ssh-keygen
ssh-copy-id <IP_address>
ssh <IP_address>
Also, you may need to change parameters in the hostfile (hosts.txt), such as IP addresses and number of slots (CPU cores).
To execute the sequential version with or without profiling, run the following respective commands:
-
Without profiling:
make sequential
-
With profiling (gprof):
make with_prof
-
To execute the program's parallel version with shared memory and OpenMP (You may need to alter the number of threads in the source code - divisors.h), run the following commands:
make sh_omp
-
Run the following command for executing the program in an unique multicore machine with shared memory:
make shared_run
-
Run the following command for executing the program in multiple machines with distributed memory:
make distributed_run
-
Run the following for executing the parallel program in multiple machines (Distributed memory - MPI | Shared memory - OpenMP):
make hybrid
Inside instances directory, you can generate your own instances by executing the command using the following template: python3 instance_generator.py --length <number> --quantity <number>
-
Example: Generating an instance file with 10000 numbers, 30 bits long:
python3 instance_generator.py -l 30 -n 10000
Inside plotting directory, you can generate the time graphics presented in this works report by running the following commmand:
python3 times.py
Also, you can generate the graphics that compares execution time between the two libraries (OpenMP and Open MPI) with shared and distributed memory, just by running the following commmand:
python3 benchmark.py