Jump to my Home Page Send me a message Check out stuff on GitHub Check out my photography on Instagram Check out my profile on LinkedIn Check out my profile on reddit Check me out on Facebook

Mitch Richling: Example MPI Programs

Author: Mitch Richling
Updated: 2023-11-15

Table of Contents

1. Introduction

Simple example programs to get you started with the MPI (Message Passing Interface) API commonly used for massively parallel, high performance compute tasks.

Get it all on github: https://github.com/richmit/ex-MPI/

2. Hello World!

helloC.c, helloCPP.cpp, helloF77.f77, helloF90.f90, helloF77.f
In the best K&R tradition, this is the "Hello World" program for MPI! I have provided C, C++, Fortran 90, and FORTRAN 77 versions just to give you an idea what the three language interfaces to MPI look like.</dd>
intStuffC.c
Illustrates how to check for MPI errors (stuff left out of the "Hello World" programs for reasons of clarity).

3. Simple Blocking Point to Point Communication

sendRecvC.c
Simple example of send/recv as typically used with no error checking.
sendRecvErrC.c
Illustrates a simple way to avoid deadlock in the face of slave failure while using point to point blocking I/O.

4. Collective Communication

reduceC.c
Illustrates the MPI_Gather, MPI_Bcast, and MPI_Reduce functions.

5. Communication Groups

groupsC.c
Illustrates a typical use of MPI groups and communicators.

6. Miscellaneous Topics

barrierC.c
Simple synchronization with the MPI_Barrier function.

7. MPI Implementation Specific

runOpenMPIjob.sh
Simple little script that creates a host file and runs an MPI job with Open MPI. Note that the runLAMjob.sh and runMPICHjob.sh scripts are no longer here as I no longer use LAM or MPICH.