X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/de0ff2cd86dbc1c499d1adbaa732c277f35a3965..8d628b79ad8699f85bc5483891b6834161709c07:/src/smpi/smpirun.in diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index ad8aabe088..ac444b7075 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -23,7 +23,7 @@ NETWORK_BANDWIDTH="${DEFAULT_NETWORK_BANDWIDTH}" NETWORK_LATENCY="${DEFAULT_NETWORK_LATENCY}" SPEED="${DEFAULT_SPEED}" -PRIVATIZE="--cfg=smpi/privatize-global-variables:yes" +PRIVATIZE="--cfg=smpi/privatization:@HAVE_PRIVATIZATION@" SIMOPTS="--cfg=surf/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP-gamma:4194304" @@ -33,7 +33,7 @@ usage () { Usage: $0 [OPTIONS] -platform -hostfile program [program-options] Options: -keep-temps # don't remove the generated files after execution - -wrapper # use command to run the program (e.g. "valgrind") + -wrapper # use command to run the program (e.g. "valgrind" or "gdb --args") -map # display the machine on which each process rank is mapped -np # use that amount of processes from the hostfile. # By default, all processes of the hostfile are used. @@ -206,6 +206,7 @@ while true; do ;; "-keep-temps") KEEP="true" + SIMOPTS="$SIMOPTS --cfg=smpi/keep-temps:yes" shift 1 ;; "-wrapper") @@ -241,11 +242,15 @@ while true; do 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 @@ -376,7 +381,6 @@ 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 @@ -414,13 +418,13 @@ set -- $hostnames ##---- generate tags------------------------------ #prepare arguments at once for ARG in $PROC_ARGS; do - ARGS="$ARGS"" + XML_ARGS="${XML_ARGS}"" " done for i in ${SEQ} do - j=$(( $i % ${NUMHOSTS} + 1 )) + j=$(( $i % ${hostfile_procs} + 1 )) host=$(eval "echo \${$j}") ##---- optional display of ranks to process mapping @@ -438,7 +442,7 @@ do echo " " >> ${APPLICATIONTMP} fi else - echo ${ARGS} >> ${APPLICATIONTMP} + echo ${XML_ARGS} >> ${APPLICATIONTMP} fi echo " " >> ${APPLICATIONTMP} done @@ -486,7 +490,7 @@ fi export SMPI_GLOBAL_SIZE=${NUMPROCS} if [ -n "${KEEP}" ] ; then - echo ${EXEC} ${TRACEOPTIONS} ${SIMOPTS} ${PRIVATIZE} ${PLATFORMTMP} ${APPLICATIONTMP} + echo ${EXEC} ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP} if [ ${HOSTFILETMP} = 1 ] ; then echo "Generated hostfile ${HOSTFILE} kept." fi @@ -506,13 +510,29 @@ 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