OpenMPI
OpenMPI Building a MPI program OpenMPI Documentation |
OpenMPI
The Open MPI Project (MPI stands for the Message Passing Interface) is an open source MPI-2 implementation that is developed and maintained by a consortium of academic, research, and industry partners.
Implementation
The current version of OpenMPI is 1.8.7 at regulus and 1.2.6 at teazer.
Setting up the OpenMPI environment
To use the OpenMPI software it is helpful to add the MPI path to your PATH variable. In order to do so you can do this interactive or you place the following entry after the global definitions in your ".bashrc" file, if you want to use this module permanent after every login. Please load only one of the OpenMPI modules:
Compiler | .bashrc entry / modulefile command |
---|---|
GNU Compiler GNU 4.4.7 at regulus (gcc, gfortran) GNU 4.1.2 at teazer (gcc, gfortran) |
module load openmpi/1.8.7_gcc447 module load openmpi/1.2.6_gnu-4.1.2 |
INTEL Compiler INTEL 15.0 at regulus (icc, icpc, ifort) |
module load openmpi/1.8.7_intel-15.0 or module load openmpi/1.8.7 |
Building a MPI program
MPI include directives
You have to add the following include file to your source files:
#include "mpi.h" (in C/C++)
include 'mpif.h' (in Fortran)
You can find these include files under:
Compiler | Include path |
---|---|
GNU Compiler GNU 4.4.7 at regulus (gcc, gfortran) GNU 4.1.2 at teazer (gcc, gfortran) |
/opt/software/mpi/openmpi/1.8.7/gcc64/include /opt/openmpi/1.2.6/include |
INTEL Compiler INTEL 15.0 at regulus (icc, icpc, ifort) |
/opt/software/mpi/openmpi/1.8.7/intel64/include |
MPI compiler scripts
The Open MPI team strongly recommends that you simply use 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 | Wrapper compiler name | Compiler script |
---|---|---|
C | mpicc | C Compiler (gcc or icc) |
C++ | mpicxx, mpiCC, or mpic++ |
C++ Compiler (g++ or icpc) |
F77 | mpif77 | Fortran 77 Compiler (f77 or ifort) |
F90 | mpif90 | Fortran 90 Compiler (gfortran or ifort) |
This is a simple compiler call that compiles the C program myprog.c .
mpicc -o myprog myprog.c
MPI libraries
If you do not use the compiler scripts you have to add the MPI libraries to your link command explicitly. Here are the paths to the libraries:
compiler | Library path |
---|---|
GNU Compiler GNU 4.4.7 at regulus (gcc, gfortran) GNU 4.1.2 at teazer (gcc, gfortran) |
/opt/software/mpi/openmpi/1.8.7/gcc64/lib /opt/openmpi/1.2.6/lib |
INTEL Compiler INTEL 15.0 at regulus (icc, icpc, ifort) |
/opt/software/mpi/openmpi/1.8.7/intel64/lib |
OpenMPI Documentation
You can find the OpenMPI documentation on the following web and man pages:
- OpenMPI
- OpenMPI FAQ
- Man Pages: mpicc(1), mpicxx(1), mpic++(1), mpiCC(1), mpif77(1), mpif90(1), mpirun(1), mpiexec(1), orterun(1).
Adapted from http://www.uibk.ac.at/zid/systeme/hpc-systeme by courtesy of the ZID HPC Team.