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. MPI addresses primarily the message-passing parallel programming model, in which data is moved from the address space of one process to that of another process through cooperative operations on each process. The MPI standard (MPI-1, MPI-2 and MPI-3) 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.

The MPI standard includes but not limit to:

  • Point-to-point communication
  • Datatypes
  • Collective operations
  • Process groups
  • Communication contexts

What is MPICH?

MPICH is a freely available, high performance and widely portable implementation of Message Passing Interface(MPI), a standard for message-passing libraries for distributed-memory applications used in parallel computing.

What does MPICH stands for?

MPI stands for Message Passing Interface. The CH comes from Chameleon, the portability layer used in the original MPICH to provide portability to the existing message-passing systems.

What is the different between MPICH1, MPICH2 and MPICH (v3)?

MPICH1 implemented MPI-1 standard while MPICH2 is an all-new the implementation of MPI standard, with implementations of MPI-1 and MPI-2 functionality. MPICH2 includes additional features supporting one-side communication, dynamic processes, intercommunicator collective operations, and expanded MPI-IO functionality.

Start from November 2012, the MPICH2 project is renamed nack to MPICH with a version number of 3.0. MPICH (v3) implements MPI-3 standard which contains significant extensions to MPI functionality, including non-blocking collectives, new one-sided communication operators, and Fortran 2008 bindings.

Which MPI version to use?

MPI-3 is the latest version of MPI standard. It includes new Fortran 2008 bindings while it removes deprecated C++ bindings and deprecated routines and MPI objects. We suggest you use MPI-3 since better solutions were provided with newer versions of MPI. 

MPICH2 replaces MPICH1 and should be used instead of MPICH1 except for the case users requiring the communication of heterogeneous data representations (e.g., different lengths for integers or different byte ordering). 

How to use MPICH?

On HPC2015, you can set the required environment variables and path by loading the module.

HPC2015 system
MPI version Compiler module command
MPICH 3.1.3 PGI Compiler 15.7 module load mpich/pgi/3.1.3
3.1.4 INTEL Compiler module load intel mpich/intel/3.1.4
GNU Compiler (GCC) module load mpich/gcc/3.1.4
3.2.0 PGI Compiler 17.7 module load mpich/pgi/3.2.0
3.2.1 18.5 module load mpich/pgi/3.2.1

To know which MPI compiler you are using, you may type command:

mpicc -v or mpicc -V


Compiling MPI program

Ensure suitable PATH of MPICH version you would like to use is defined in your ~/.bashrc file or load the module.
For MPI C/C++ programs :

mpicc program.c -o program.exe or mpic++ program.cpp -o program.exe

For MPI Fortran 77 or Fortran 90 programs:

mpif77 program.f -o program.exe or mpif90 program.f90 -o program.exe

Running MPICH program

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

mpirun -np 20 ./program.exe

(B) Sample MPICH PBS script for batch run:

#PBS –N test_mpi
#PBS -q parallel
#PBS -l walltime=00:10:00

#PBS -l nodes=1:ppn=8

#PBS -j oe

NNODES=`uniq $PBS_NODEFILE | wc -l`
cat $PBS_NODEFILE | uniq |awk -v nc=$NCORES '{print $1":"nc}' > $MACHFILE 

mpirun -machinefile ${MACHFILE} -np ${NPROCS} ./program.exe 

rm -f ${MACHFILE} 

A complete and detailed sample PBS script (for MPICH1/MPICH) is provided at your home directory: pbs-mpi.cmd

Additional Information

MPICH Homepage: http://www.mpich.org/‎
MPICH user guide and tutorial: http://www.mpich.org/documentation/guides/
MPI Programming Self-learn tutorial