Homework 10 (in-class), 11/17
Adding OpenMP threading to a simple MPI application
Take a look at the Hello World applications included in the work
repo. These include MPI functionality. Modify one of these applications to include OpenMP. Working within your group, pick one group member to do the programming and share their screen.
- Wrap the print statements in an
omp parallel
region. - Make sure to modify the
MPI_Init
call accordingly to allow for threads! What level of thread support do you need? - Compile the code including the appropriate flag for OpenMP support. For a GCC-based MPI installation, this would be, e.g.,
mpic++ -fopenmp hello.cpp
. - Run the code using 2 MPI ranks and 4 OpenMP threads per rank. To do this, prior to executing the run command, set the number of threads environment variable as
> export OMP_NUM_THREADS=4
. Then you can simply execute the application with thempirun
command:> mpirun -n 2 ./a.out
. - Explain the output.
What to turn in
Nothing!