Message Passing Interface (MPI): Tutorials
Systems & Access :: Learning to Use :: Sun Computing Resource
Some general information about MPI and tutorials on how to use it are available from numerous sites, including the following places, among others:
Installation details of MPICH
MPICH is an open-source, portable implementation of the Message-Passing Interface Standard. It contains a complete implementation of version 1.2 of the MPI Standard and also significant parts of MPI-2,; particularly in the area of parallel I/O. MPICH is both a run-time and compile-time environment for MPI-compliant code.
mpich versions:
Solaris:
mpich 1.2.6 - open source Message Passing Interface
The Solaris builds support the "shmem", "p4", and "p4shmem" devices. Use "shmem" to run your job on single shared-memory smp machines such as almaak (rcf-01). Use "p4" to run on a cluster of machines, such as HPCC's ~120 node condor flock. "p4shmem" is a combination of the two devices for clusters of smp machines; ithat are specifically for the Southern California Earthquake Center (SCEC) users. The "p4shmem" is not particularly useful in almaak's PBS queue.
Compilers
MPICH is built with support for several different compiler sets, but the user must choose one. MPICH supports C, C++, F77, and F90. MPICH is tightly integrated with the operating system and the compiler set the user intends to use. This version of mpich was built with various sets of compilers:
Solaris:
GNU - Open source compiler from the GNU project (2.95.2)
SPAC - Native Solaris sparc compilers
To add the preferred device/compiler sets to your environment automatically (shmem-spac on Solaris), add the following to your .login:
if ( -e /usr/usc/mpich/1.2.4/setup.csh) then
source /usr/usc/mpich/1.2.4/setup.csh
endif
If you use the the Bourne shell add the following lines to .bash_profile (or .profile in case you dont have a .bash_profile):
if [ -e /usr/usc/mpich/1.2.4/setup.sh ]; then
source /usr/usc/mpich/1.2.4/setup.sh
fi
Examples of other available setup files are:
/usr/usc/mpich/1.2.4/p4-gnu/setup.csh
/usr/usc/mpich/1.2.4/shmem-spac/setup.csh
etc.
Compiling
MPICH includes wrapper scripts designed to hide the details of compiling with any particular build or compiler. Simply source an mpich build into your shell environment and use mpicc, mpiCC, mpif77, or mpif90 to compile your code. The arguments to the script are passed to the compile and interpreted normally. The wrapper script will link in the correct libraries and add rpaths as necessary.
Running
MPICH includes a wrapper script called mpirun(1) to hide the details of getting your program to run. To use mpirun, it is critical that the exact same mpich build that was used to build the program is also used to run it. After sourcing the correct mpich build, mpirun requires a few arguments to tell it which nodes to run on. The two most common options are -machinefile and -np. Under PBS or TORQUE, simply pass $PBS_NODEFILE to -machinefile. The number of processors will need to be passed to -np. Under PBS or TORQUE, the easiest way to get the value for -np is:
cat $PBS_NODEFILE | wc -l
Documentation
The official MPICH documentation is at http://www.mcs.anl.gov/mpi/mpich.