#! /bin/csh
# This script runs the test programs for communications performance
if ($argv > 1) then
    if ("$1" == "-help") then 
        echo "Run a test suite 
set MAXNP = 2
if ($argv > 1) set MAXNP = $1
set PARCH = workstations
#
# The following isn't quite right yet....
set GETMACHINE = 'echo "Starting..." '
set RELMACHINE = 'echo "...Done" '
set RUNPGM = ""
if ($PARCH == intelnx) then
    set GETMACHINE = "getcube -n$NP ; "
    set RELMACHINE = "waitcube ; relcube ;"
    set RUNPGM = "load $PGM $ARGS"
else if ($PARCH == inteldelta) then
    set GETMACHINE = "msh -t\(\)"
    set RUNPGM     = 'msh -t\(\) $PGM -a "$ARGS" '
    set RELMACHINE = '; echo "...Done" '
endif

#
# Speed of individual links
set PGM = twin
$GETMACHINE
foreach SIZES ("0 1024 32" "1024 16394 512")
    foreach KIND ("" -sync -async -force)
	set ARGS = "$KIND -size $SIZES -np 2"
	echo "$PGM $ARGS"
        $RUNPGM $PGM $ARGS
    end
end
$RELMACHINE

#
# Speed of collective operations
set NP = 2
set PGM = gop
while ($NP < $MAXNP)
    $GETMACHINE
    foreach ISNATIVE ("" "-native")
        foreach PACKETS ("256 16394 256")
            foreach SIZES ("0 1024 32" "1024 16394 512")
                foreach KIND ( -dsum -sync -scatter -col )
	            foreach TOPOLOGY ( -ring -tree )
		        set ARGS = "-np $NP $ISNATIVE $KIND -size $SIZES -pkt $PACKETS $TOPOLOGY"
		        echo "$PGM $ARGS"
    		        $RUNPGM $PGM $ARGS
		    end
		end
	    end
 	end
    end
    $RELMACHINE
    @ NP = 2 * $NP
endwhile

#
# Checkout entire machine
set NP = $MAXNP
set PGM = tcomm
$GETMACHINE
foreach SIZES ("0 1024 32" "1024 16394 512")
    foreach KIND ("" -async -force)
	set ARGS = "-np $NP -size $SIZES $KIND"
	echo "$PGM $ARGS"
        $RUNPGM $PGM $ARGS
    end
end
$RELMACHINE
