Introduction to MPI Programming

The goal of this section is to introduce you to MPI programming using OpenMPI.

Hands-on

Remember to setup the environment as described in the Environment section:

1) ssh passwordless

2) shared working directory (you have to do nothing, is already there)

3) setup the correct export for PATH and LD_LIBRARY_PATH in the .bashrc

Check that your environment is correctly configured to compile MPI code by running:

$ mpic++ --version
g++ (GCC) 14.3.1 20251022 (Red Hat 14.3.1-4)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ which mpic++
/opt/hpcx-v2.25.1-gcc-doca_ofed-redhat9-cuda13-x86_64/ompi/bin/mpic++
$ which mpirun
/opt/hpcx-v2.25.1-gcc-doca_ofed-redhat9-cuda13-x86_64/ompi/bin/mpirun

Compile and run the MPI executable:

$ cd esc26/hands-on/mpi
$ mpic++ -o MPI_Hello.out MPI_Hello.cpp
$ mpirun  -n 2 MPI_Hello.out
$ mpirun -hostfile machinefile.txt -n 2 MPI_Hello.out

You can now go and try with the other exercises avalble on the esc25/hands-on/mpi directory (see the slides for more details):

1) The MPI PingPong

2) The Non Blocking MPI PingPong

3) The MPI Pi Computation

4) The Trivial MPI N_Body Simulation

5) The Trivial Conway’s Game-of-Life