while true; do
case "$1" in
- "-np")
+ "-np" | "-n")
NUMPROCS="$2"
shift 2
;;
NETWORK_LATENCY="$2"
shift 2
;;
- "-help")
+ "-platform")
+ PLATFORM="$2"
+ shift 2
+ ;;
+ "-hostfile")
+ HOSTFILE="$2"
+ shift 2
+ ;;
+
+ "-help" | "--help" | "-h")
echo "usage:"
- echo "$0 [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
+ echo "$0 [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] [-platform <xmldesc>] [-hostfile <hostfile>] program [program-options]"
echo
exit
;;
EXEC="$1"
shift
-PLATFORMTMP="$(mktemp tmpXXXXXX)"
-#PLATFORMTMP="pla.xml"
+##-------------------------------- DEFAULT or SPECIFIED PLATFORM --------------------------------------
+if [ -z "${PLATFORM}" ]; then
+ PLATFORMTMP="$(mktemp tmpXXXXXX)"
+ #PLATFORMTMP="pla.xml"
-cat > ${PLATFORMTMP} <<PLATFORMHEAD
+ cat > ${PLATFORMTMP} <<PLATFORMHEAD
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "simgrid.dtd">
<platform version="2">
</platform>
PLATFORMFOOT
+else
+ PLATFORMTMP=${PLATFORM}
+fi
+##-------------------------------- end DEFAULT or SPECIFIED PLATFORM --------------------------------------
+
+##-------------------------------- DEFAULT APPLICATION --------------------------------------
APPLICATIONTMP="$(mktemp tmpXXXXXX)"
#APPLICATIONTMP="app.xml"
+
cat > ${APPLICATIONTMP} <<APPLICATIONHEAD
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "simgrid.dtd">
<platform version="2">
APPLICATIONHEAD
+##---- cache hostnames of hostfile---------------
+if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
+ hostnames=(`cat ${HOSTFILE} | tr \\\n " "`)
+fi
+
+##----------------------------------------------------------
+## generate application.xml with hostnames from hostfile:
+## the name of host_i (1<=i<=p, where -np p) is the line i
+## in hostfile (where -hostfile hostfile), or "host$i" if
+## hostfile has less than i lines.
+##----------------------------------------------------------
for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
- echo " <process host=\"host$i\" function=\"smpi_simulated_main\">" >> ${APPLICATIONTMP}
+ j=$(( $i-1 ))
+ if [ -z "${hostnames[$j]}" ]; then
+ host="host"$i
+ else
+ host="${hostnames[$j]}"
+ fi
+ echo " <process host=\"${host}\" function=\"smpi_simulated_main\">" >> ${APPLICATIONTMP}
for ARG in $*; do
echo " <argument value=\"${ARG}\"/>" >> ${APPLICATIONTMP}
done
done
for (( i=${NUMPROCS}; $i ; i=$i-1 )) do
- echo " <process host=\"host$i\" function=\"smpi_sender\"/>" >> ${APPLICATIONTMP}
- echo " <process host=\"host$i\" function=\"smpi_receiver\"/>" >> ${APPLICATIONTMP}
+ j=$(( $i-1 ))
+ if [ -z "${hostnames[$j]}" ]; then
+ host="host"$i
+ else
+ host="${hostnames[$j]}"
+ fi
+
+ echo " <process host=\"${host}\" function=\"smpi_sender\"/>" >> ${APPLICATIONTMP}
+ echo " <process host=\"${host}\" function=\"smpi_receiver\"/>" >> ${APPLICATIONTMP}
done
cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
</platform>
APPLICATIONFOOT
+##-------------------------------- end DEFAULT APPLICATION --------------------------------------
${EXEC} ${PLATFORMTMP} ${APPLICATIONTMP}
-rm ${PLATFORMTMP} ${APPLICATIONTMP}
+
+echo "[$0] cleaning up temp files"
+if [ -z "${PLATFORM}" ]; then
+ rm ${PLATFORMTMP}
+fi
+rm ${APPLICATIONTMP}