What is MPI?

MPI stands for the Message Passing Interface. It is a standard define and maintain by the MPI Forum used for parallel and/or distributed computing. The MPI standard defines syntax ans semantics of library routines useful for users writing portal message-passing programs in varies programming languages. The primary goals of MPI are high efficiency, functionality and portability.

What is Open MPI?

The Open MPI Project is an open source, freely available implementation of MPI with MPI-1, MPI-2 and MPI-3 standards.

Using Open MPI

On HPC2015, you can set up the Open MPI environment variables and path by loading the module:

HPC2015 system
Open MPI version Compiler module command
1.6.5 GNU Compiler (GCC) module load openmpi/gcc/1.6.5
INTEL Compiler module load openmpi/intel/1.6.5
1.8.4 PGI Compiler 15.7 module load openmpi/pgi/1.8.4
1.8.8 GNU Compiler (GCC) module load openmpi/gcc/1.8.8
INTEL Compiler module load openmpi/intel/1.8.8
1.10.2 PGI Compiler 17.7 module load openmpi/pgi/1.10.2
1.10.6 GNU Compiler (GCC) module load openmpi/gcc/1.10.6
2.1.0 GNU Compiler (GCC) module load openmpi/gcc/2.1.0
INTEL Compiler module load openmpi/intel/2.1.0
2.1.2 PGI Compiler 18.5 module load openmpi/pgi/2.1.2

Compiling MPI applications

You can use the Open MPI’s wrapper compilers to compile your MPI applications. That is, instead of using (for example) gcc to compile your program, use mpicc. Open MPI provides a wrapper compiler for four languages:

Language Environment variable Wrapper compiler name
C $MPICC mpicc
C++ $MPICXX mpicxx, mpic++
Fortran $MPIFC mpifort (for v1.7 and above)
$MPIF90 mpif90
$MPIF77 mpif77

Therefore, you can compile your MPI programs by:

mpicc mpi_program.c -o mpi_program

Note that Open MPI’s wrapper compilers do not do any actual compiling or linking; all they do is manipulate the command line and add in all the relevant compiler/linker flags and then invoke the underlying compiler/linker. You may visit Open MPI FAQ for additional information.

Running Open MPI program

(A) Interactive run (for short job testing):

mpiexec -n 8 ./mpi_program

(B) Sample PBS script for batch run:

#PBS –N test_openmpi
#PBS -q parallel
#PBS -l walltime=00:10:00
#PBS -l nodes=2:ppn=10
#PBS -j oe


mpiexec -n ${NPROCS} ./mpi_program > ${PBS_JOBNAME}.${PBS_JOBID} 
# end of example file

Additional Information

Official Open MPI website: http://www.open-mpi.org/
Official documentation for different Open MPI versions
MPI Programming Self-learn tutorial