#!/bin/sh
# This are settings for running MPI tests
# This is the directory where test suite is unpacked
MPIBENCH_HOME=/home/alex/benchmarks/MPI-Suite
# Default number of MPI processes to run
NNODES='4'
# Default repeat flag for all tests
REPEAT=R1
# Head process flag
HEAD=H0
# Name given to the series of experiements
SERIES='sci-run1'
# Directory where the executables are placed
BINDIR=${MPIBENCH_HOME}/bin
# Output directory and/or file
# if running in batch mode, remove the value of OUTPUT
#OUTPUT="o${SERIES}.dat"
OUTPUT=
#OUTDIR=../res
OUTDIR=${MPIBENCH_HOME}/res/${SERIES}
# How do we run our MPI tasks
RUNTASK=${MPIBENCH_HOME}/scripts/runtask-qs
# Please check the contents "runtask" script!
# Its first argument must be number of processes,
# the other are MPI program with all parameters

# You may also need to decrease number of processors in "for" loops (see below)

# Sample run file for all tests together 
# You may need to correct some parameters for your system
# Tested on SRCC cluster
#        Alexander Andreyev, alexander@parallel.ru
#
TST=`echo -e`
if [ "X$TST" != "X-e" ]; then
  E='-e'
else
  E='';
fi


HOSTNAME=`hostname`
DATE=`date`
USER=`whoami`
echo Running on $HOSTNAME at $DATE as user $USER

echo Running MPI programs with ${RUNTASK}, ${NNODES} nodes, head process $HEAD, output in ${SERIES}.dat
echo Please note, that if you are running tests with queue system, you should not use output flag ${OUTPUT}
echo Creating output directory $OUTDIR

mkdir -p $OUTDIR

echo Changing directory to $OUTDIR, running binaries from $BINDIR

cd $OUTDIR

#
echo $E "\n============ Running test group 0 (LATENCY) ============\n"
echo $E "\n>>> START [0] <<<\n"
$RUNTASK $NNODES $BINDIR/transf1 m0 M0 T100000 f1000 $HEAD $REPEAT $OUTPUT 
echo $E "\n>>>   END [0] <<<\n"

#
echo $E "\n============ Running test group 1 (TRANSFER) ============\n"
echo $E "\n>>> START [1a] <<<\n"
for n in 1 2 3 4 5; do
$RUNTASK $NNODES $BINDIR/transf$n m0 M256 s4 Ptime T100 f100 $HEAD $REPEAT $OUTPUT  ; done
echo $E "\n>>>   END [1a] <<<\n"

echo $E "\n>>> START [1b] <<<\n"
for n in 1 2 3 4 5; do
$RUNTASK $NNODES $BINDIR/transf$n m16 M1024 s16 T100 f100 $HEAD $REPEAT $OUTPUT  ; done
echo $E "\n>>>   END [1b] <<<\n"

echo $E "\n>>> START [1c] <<<\n"
for n in 1 2 3 4 5; do
$RUNTASK $NNODES $BINDIR/transf$n m1024 M16777216 K2 T5 f100 $HEAD $REPEAT $OUTPUT  ; done
echo $E "\n>>>   END [1c] <<<\n"

echo $E "\n============ Running test group 2 (MPITEST) ============\n"
echo $E "\n>>> START [2] <<<\n"
for np in 4 $NNODES; do
$RUNTASK $np $BINDIR/mpitest m1 M100 K10 T1000 t10000  $HEAD $REPEAT $OUTPUT  ; done
echo $E "\n>>>   END [2] <<<\n"

echo $E "\n============ Running test group 3 (NETTEST) ============\n"
echo $E "\n>>> START [3] <<<\n"
for np in 4 $NNODES; do
$RUNTASK $np $BINDIR/nettest m1024 M1048576 K2 T20  $HEAD $REPEAT $OUTPUT  ; done
echo $E "\n>>>   END [3] <<<\n"

echo $E "MPI benchmark suite complete"
date
