A myriad of applications are using the combination of OpenMP constructs and MPI library in order to improve their performance. You might start MPI with this great Website 🙂
Once you have a MPI program, you may include some code in order to make it hybrid:
- Add the OpenMP header: #include <omp.h>
- Declare request and provided variables in order to check the level of threads support.
- Initialize the MPI environment properly, instead of int MPI_Init(&argc, &argv), use MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided); In this case, I choose the type Funneled but you may choose the style Master-only, Serialized, or Multiple. You can see further information about this here.
- Define the parallel block with the directives pragma parallel omp including the default, firstprivate, private and/or shared variables as your program was set.
- In your Makefile, set the FLAG= openmp or qopenmp (depends on your compiler).
- Load the modules and run it as it is, a MPI program.
The performance was test as it is shown in the table having the best option with 36 processes and 1 thread using the Funneled type. Later, the style MPI_THREAD_SINGLE with 36 process and 1 thread was set, achieving 0.0532 achieving a speed of 0.9797 with this type.
*** Compared the Single style to the Funneled, this latter one was faster. ***