Using MPICH2

MPICH2 for GNU compiler

Compiler your program

MPICH2 for GNU compiler is installed at /share/apps/mpich2/gnu. This example will demonstrate how to compiler your program using MPICH2 for GNU Compiler. We will use cpi.c as an example program

[user@tera mpich2]$ /share/apps/mpich2/gnu/bin/mpicc -o cpi cpi.c

From the above example, orange means your MPIC code program. Green means the compiled executable.

Execute your program

After you finish with compilation, you need to submit your job to scheduling system. TERA cluster is using SGE (Sun Grid Engine) as the batch scheduling system. To submit the job

  • Create job submission script for SGE, using your favorite editor such as vi or nano

    [user@tera mpich2]$ vi mpich2_test.job
  • Below are the content for example job script. Please note that, you need to replace $APP with full path to your application and $ARG with application argument. $NSLOTS and $TMPDIR will be replaced automatically by SGE.

#!/bin/bash
#$ -cwd
#$ -S /bin/bash
#$ -j y
export MPICH2_HOME=/share/apps/mpich2/intel
export MPICH2_BIN=$MPICH2_HOME/bin
export MPICH2_CONF="$HOME/.mpd.conf"
APP=/home/user1/cpi
if [ ! -r $MPICH2_CONF ]; then
        SECRET=`mkpasswd -l 7 -s 0`
        echo "secretword=$SECRET" > $MPICH2_CONF
        chmod 600 $MPICH2_CONF
fi
$MPICH2_BIN/mpdboot -n "$NHOSTS" -f "$TMPDIR/machines"

$MPICH2_BIN/mpiexec -l -machinefile $TMPDIR/machines -n $NSLOTS $APP

jobs=`$MPICH2_BIN/mpdlistjobs`
if [ X"$jobs" = X ]; then
        $MPICH2_BIN/mpdallexit
fi
  • Now submit the script to SGE. Since this application is the parallel application, user need to indicate parallel environment (highlighted in green) and a number of processors (in orange) with option -pe. Note that, you can specify queue name other than default queue by using -q option. You can find more instruction on SGE here.

    [user@tera mpich2]$ qsub -pe mpich 4 mpich2_test.job
  • To view your job status

  • [user@tera mpich2]$ qstat
  • The output and error from MPI application are created in directory where user submitted jobs.

MPICH2 for Intel Compiler

MPICH2 for Intel Compiler is recommended to be used only if you want to compile your MPI program using Intel Compiler. If you just want to simply link with MPICH2, please consider to use MPICH2 for GNU instead.

The usage of MPICH2 for Intel compiler is the same as MPICH2 for GNU compiler, except that you need to replace all path to MPICH2 compiler from /share/apps/mpich2/gnu to /share/apps/mpich2/intel.

Powered by Drupal - Design by Artinet