Message passing

Compilation using Sun MPI and Sun Studio compilers

To simplify MPI compilation, Sun has included compiler front-ends in the ClusterTools package to set the correct paths etc. The procedure is relatively simple:

1. Include the MPI headers:

INCLUDE 'mpif.h'
#include <mpi.h>

2. Compile using the front-ends:

mpf77 <flags> -dalign -lmpi

mpf90 <flags> -dalign -lmpi
mpcc <flags> -lmpi
mpCC <flags> -mt -lmpi

If your MPI code is multi-threaded you should replace the -lmpi with -lmpi_mt.

A very basic Makefile for MPI program development:

OPT     = -fast -xtarget=ultra3 -xarch=v8plusb
MPLIBS  = -lmpi 
CFLAGS  = ${OPT}
FFLAGS  = ${OPT} 
LDFLAGS = ${MPLIBS}
CC      = mpcc
FC      = mpf77
F90C    = mpf90

To run your MPI program on N processors, start it with

mprun -np N your_mpi_program 

If mprun complains that it cannot find your program, use the following line instead:

mprun -np N ./your_mpi_program 

It simply means that you do not have the current directory (.) in your PATH settings.

Once the program is started you can monitor the MPI job using several tools.

mpps

shows you your current running MPI jobs, use the flag -e to see all running MPI jobs.

mpkill <job_id>

kills a running MPI job using the ID given to you at run time or from mpps.

Note: Please use the GridEngine queuing system to run your programs on the HPC machines. An example job script for submitting MPI jobs is provided in the GridEngine section of this website.