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 me out on Facebook

Example MPI Programs

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

Hello World!

helloC.c helloCPP.cpp helloF77.f77 helloF90.f90
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.
intStuffC.c
Illustrates how to check for MPI errors (stuff left out of the "Hello World" programs for reasons of clarity).

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.

Collective Communication

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

Communication Groups

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

Miscellaneous Topics

barrierC.c
Simple synchronization with the MPI_Barrier function.

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.
© 2009 Mitch Richling