#! /bin/sh
-# Copyright (c) 2007-2015. The SimGrid Team.
-# All rights reserved.
+# Copyright (c) 2007-2016, The SimGrid Team. All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the terms of the license (GNU LGPL) which comes with this package.
NETWORK_LATENCY="${DEFAULT_NETWORK_LATENCY}"
SPEED="${DEFAULT_SPEED}"
+PRIVATIZE="--cfg=smpi/privatization:@HAVE_PRIVATIZATION@"
+
SIMOPTS="--cfg=surf/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP-gamma:4194304"
#usage to print the way this script should be called
Usage: $0 [OPTIONS] -platform <xmldesc> -hostfile <hostfile> program [program-options]
Options:
-keep-temps # don't remove the generated files after execution
- -wrapper <command> # use command to run the program (e.g. "valgrind")
+ -wrapper <command> # use command to run the program (e.g. "valgrind" or "gdb --args")
-map # display the machine on which each process rank is mapped
-np <numprocs> # use that amount of processes from the hostfile.
# By default, all processes of the hostfile are used.
+ -no-privatize # Disable the globals privatization, that is activated by default
-trace-ti # activate time independant tracing (for replay, default in smpi_simgrid.txt)
-trace # activate tracing (Paje, default in smpi_simgrid.trace)
-trace-comment <comment> # put a comment on the top of the trace file
WRAPPER=""
HOSTFILE=""
HOSTFILETMP=0
+MAPOPT=0
+REPLAY=0
unset pid
EXTOPT="$2"
shift 2
;;
+ "-no-privatize")
+ PRIVATIZE=""
+ shift 1
+ ;;
"-map")
- MAPOPT="true"
+ MAPOPT=1
shift 1
;;
"-trace")
;;
"-keep-temps")
KEEP="true"
+ SIMOPTS="$SIMOPTS --cfg=smpi/keep-temps:yes"
shift 1
;;
"-wrapper")
esac
done
-if [ -n "$WRAPPER" ]; then
- EXEC="$WRAPPER $1"
-else
- EXEC="$1"
+# check if we still have at least one parameter beyond options
+if [ $# -eq 0 ]
+then
+ echo "Error: no program to execute!"
+ usage
+ exit
fi
+
+EXEC="$1"
shift
# steel --cfg and --logs options
fi
if [ ${NUMPROCS} -gt ${hostfile_procs} ] ; then
- echo "You requested to use ${NUMPROCS} processes, but there is only ${hostfile_procs} processes in your hostfile..." >&2
+ echo "You requested to use ${NUMPROCS} ranks, but there is only ${hostfile_procs} processes in your hostfile..." >&2
fi
##-------------------------------- DEFAULT or SPECIFIED PLATFORM --------------------------------------
cat > ${PLATFORMTMP} <<PLATFORMHEAD
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-<AS id="AS0" routing="Full">
+<platform version="4.1">
+<zone id="AS0" routing="Full">
PLATFORMHEAD
i=${NUMPROCS}
done
cat >> ${PLATFORMTMP} <<PLATFORMFOOT
-</AS>
+</zone>
</platform>
PLATFORMFOOT
cat > ${APPLICATIONTMP} <<APPLICATIONHEAD
<?xml version='1.0'?>
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
+<platform version="4.1">
APPLICATIONHEAD
##---- cache hostnames of hostfile---------------
if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
hostnames=$(cat ${HOSTFILE} | tr '\n\r' ' ')
- NUMHOSTS=$(cat ${HOSTFILE} | wc -l)
fi
if [ "${EXTOPT}" = "smpi_replay" ]; then
if [ -n "${APP_TRACES}" ] && [ -f "${APP_TRACES}" ]; then
hosttraces=$(cat ${APP_TRACES} | tr '\n\r' ' ' )
NUMTRACES=$(cat ${APP_TRACES} | wc -l)
+ REPLAY=1
else
printf "File not found: %s\n" "${APP_TRACES:-\${APP_TRACES\}}" >&2
exit 1
done
fi
-##---- generate <process> tags------------------------------
+set -- $hostnames
+
+##---- generate <actor> tags------------------------------
+#prepare arguments at once
+for ARG in $PROC_ARGS; do
+ XML_ARGS="${XML_ARGS}""<argument value=\"${ARG}\"/>
+"
+done
+
for i in ${SEQ}
do
- if [ -n "${HOSTFILE}" ]; then
- j=$(( $i % ${NUMHOSTS} + 1 ))
- fi
- ##---- optional display of ranks to process mapping
- if [ -n "${MAPOPT}" ]; then
- echo "[rank $i] -> $(echo $hostnames|cut -d' ' -f$j)"
- fi
+ j=$(( $i % ${hostfile_procs} + 1 ))
+ host=$(eval "echo \${$j}")
- if [ -z "$(echo $hostnames|cut -d' ' -f$j)" ]; then
- host="host"$($j)
- else
- host="$(echo $hostnames|cut -d' ' -f$j)"
+ ##---- optional display of ranks to actor mapping
+ if [ ${MAPOPT} = 1 ]; then
+ echo "[rank $i] -> $host"
fi
- echo " <process host=\"${host}\" function=\"$i\"> <!-- function name used only for logging -->" >> ${APPLICATIONTMP}
- echo " <argument value=\"1\"/> <!-- instance -->" >> ${APPLICATIONTMP}
- echo " <argument value=\"$i\"/> <!-- rank -->" >> ${APPLICATIONTMP}
- if [ "${EXTOPT}" = "smpi_replay" ]; then
+
+ echo " <actor host=\"${host}\" function=\"$i\"> <!-- function name used only for logging -->
+ <argument value=\"1\"/> <!-- instance -->
+ <argument value=\"$i\"/> <!-- rank -->" >> ${APPLICATIONTMP}
+ if [ ${REPLAY} = 1 ]; then
if [ ${NUMTRACES} -gt 1 ]; then
echo " <argument value=\"$(echo $hosttraces|cut -d' ' -f$j)\"/>" >> ${APPLICATIONTMP}
else
echo " <argument value=\"$(echo $hosttraces|cut -d' ' -f1)\"/>" >> ${APPLICATIONTMP}
fi
else
- for ARG in $PROC_ARGS; do
- echo " <argument value=\"${ARG}\"/>" >> ${APPLICATIONTMP}
- done
+ echo ${XML_ARGS} >> ${APPLICATIONTMP}
fi
- echo " </process>" >> ${APPLICATIONTMP}
+ echo " </actor>" >> ${APPLICATIONTMP}
done
cat >> ${APPLICATIONTMP} <<APPLICATIONFOOT
export SMPI_GLOBAL_SIZE=${NUMPROCS}
if [ -n "${KEEP}" ] ; then
- echo ${EXEC} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP}
+ echo ${EXEC} ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP}
if [ ${HOSTFILETMP} = 1 ] ; then
echo "Generated hostfile ${HOSTFILE} kept."
fi
# * The FD 3 is used to temporarily store FD 1. This is because the shell connects FD 1 to /dev/null when the command
# is launched in the background: this can be overriden in bash but not in standard bourne shell.
exec 3<&0
-${EXEC} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP} <&3 3>&- &
+${WRAPPER} "@SMPIMAIN@" ${EXEC} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP} <&3 3>&- &
pid=$!
exec 3>&-
wait $pid
status=$?
pid=""
+# Keep temporary files on failures to help debugging
+#
+if [ ${status} -ne 0 ] ; then
+ if [ -z ${KEEP} ]; then
+ echo ${EXEC} ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP}
+ if [ ${HOSTFILETMP} = 1 ] ; then
+ echo "Generated hostfile ${HOSTFILE} kept."
+ fi
+ if [ ${UNROLLEDHOSTFILETMP} = 1 ] ; then
+ echo "Generated unrolled hostfile ${UNROLLEDHOSTFILE} kept."
+ fi
+ fi
+ echo "Execution failed with code ${status}."
+ KEEP=true
+fi
+
smpirun_cleanup
exit $status