Building OpenMPI Programs

OpenMPI programs are those written to the MPI specification and linked with the Scyld ClusterWare OpenMPI libraries. This section discusses how to build (or compile) OpenMPI programs on Scyld ClusterWare using open source and commercial compilers.

OpenMPI mpicc, mpiCC, mpif77 and mpif90

Scyld ClusterWare provides the mpicc, mpiCC, mpif77 and mpif90 compile wrappers to build C, C++, Fortran 77 and Fortran 90 OpenMPI binaries. Unlike MPICH, there exists a set of wrapper for various compilers. The env-modules package provides an easy means for the user to switch between the various compilers. Be sure to load the correct module to favor the OpenMPI wrappers so that you do not use the MPICH compile wrappers found in /usr. For example, to compile the C program my_prog.c using the GNU compiler:

 [user@cluster ~]$ module load openmpi/gnu
 [user@cluster ~]$ mpicc -o my_prog my_prog.c
When you are done using OpenMPI, or if you wish to switch back to MPICH, simple unload the module:
  [user@cluster ~]$ module unload openmpi/gnu

Using non-GNU compilers to build OpenMPI programs

You can change the compiler used to build and link OpenMPI programs by loading the env-module for the compiler of your choice. For example, to compile the C program my_prog.c with the Intel icc compiler:

 [user@cluster ~]$ module load openmpi/intel
 [user@cluster ~]$ mpicc -o my_prog my_prog.c
Currently, there are modules for the GNU, Intel, and PGI compilers. To see a list of all of the available modules:
 [user@cluster ~]$ module avail openmpi
--------------------------- /opt/modulefiles -------------------------------
openmpi/gnu(default) openmpi/intel        openmpi/pgi
For more detail, or for cases where using the wrappers isn't an option, you can use -show to see how the compiler wrappers will build and link your program:
 [user@cluster ~]$ module load openmpi/intel
 [user@cluster ~]$ mpicc -o my_prog my_prog.c -show
 icc -I/usr/openmpi/include -I/usr/lib64/OMPI/intel -o my_prog my_prog.c \
     -L/usr/lib64/OMPI/intel -lmpi -lopen-rte -lopen-pal -libverbs -ldat \
     -lrt -ltorque -ldl -lnsl -lutil -lm
For more information about creating your own modules, see and the manpages man module and man modulefile.