X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3a90102759eb860fd96bc294542d3aa38f5b208d..149c63f36e15b8500b1e826bda5138318ff7ba2b:/src/smpi/smpirun.in diff --git a/src/smpi/smpirun.in b/src/smpi/smpirun.in index bf1646c33d..3a79f5a075 100755 --- a/src/smpi/smpirun.in +++ b/src/smpi/smpirun.in @@ -1,6 +1,6 @@ #!/usr/bin/env sh -# Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. +# Copyright (c) 2007-2020. 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. @@ -42,7 +42,7 @@ Options: -np # 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-ti # activate time independent tracing (for replay, default in smpi_simgrid.txt) -trace # activate tracing (Paje, default in smpi_simgrid.trace) -trace-comment # put a comment on the top of the trace file -trace-comment-file # put file contents on the top of the trace file as comment @@ -72,6 +72,7 @@ HOSTFILE="" HOSTFILETMP=0 MAPOPT=0 REPLAY=0 +QUIET="" unset pid @@ -202,6 +203,10 @@ while true; do SIMOPTS="$SIMOPTS --cfg=smpi/keep-temps:yes" shift 1 ;; + "-quiet") + QUIET="true" + shift 1 + ;; "-wrapper") WRAPPER="$2" shift 2 @@ -273,7 +278,7 @@ else shift fi -# steel --cfg and --logs options +# steal --cfg and --logs options while [ $# -gt 0 ]; do case "$1" in "--cfg="*|"--log="*) @@ -299,32 +304,47 @@ fi if [ -z "${HOSTFILE}" ] ; then HOSTFILETMP=1 HOSTFILE="$(mktemp smpitmp-hostfXXXXXX)" - perl -ne 'print "$1\n" if /.*.*/' ${PLATFORM} > ${HOSTFILE} - # put all > ${HOSTFILE} + @PYTHON_EXECUTABLE@ -c ' +import xml.etree.ElementTree as ET +import sys +import re + +tree = ET.parse(sys.stdin) + +for elem in tree.findall(".//host"): + print(elem.attrib["id"]) + +for elem in tree.findall(".//cluster"): + prefix = elem.attrib["prefix"] + radical = elem.attrib["radical"] + suffix = elem.attrib["suffix"] + for r in radical.split(","): + m = re.match("^([^-]*?)-([^-]*)$", r) + if m: + for i in range(int(m.group(1)), int(m.group(2))): + print(prefix + str(i) + suffix) + else: + print(prefix + r + suffix) + ' < ${PLATFORM} > ${HOSTFILE} fi UNROLLEDHOSTFILETMP=0 -#parse if our lines are terminated by :num_process -multiple_processes=$(grep -c ":" $HOSTFILE) -if [ "${multiple_processes}" -gt 0 ] ; then +# parse if our lines are terminated by :num_process +if grep -q ':' $HOSTFILE ; then UNROLLEDHOSTFILETMP=1 UNROLLEDHOSTFILE="$(mktemp smpitmp-hostfXXXXXX)" - perl -ne ' do{ for ( 1 .. $2 ) { print "$1\n" } } if /(.*?):(\d+).*/' ${HOSTFILE} > ${UNROLLEDHOSTFILE} + @PYTHON_EXECUTABLE@ -c ' +import sys +import re + +for line in sys.stdin: + m = re.match("(.*):(.*)", line) + if m: + for i in range(0, int(m.group(2))): + print(m.group(1)) + else: + print(line.strip()) +' < ${HOSTFILE} > ${UNROLLEDHOSTFILE} if [ ${HOSTFILETMP} = 1 ] ; then rm ${HOSTFILE} HOSTFILETMP=0 @@ -505,6 +525,8 @@ if [ -n "${TRACE_ACTIVE}" ]; then fi ##---------------------- end SMPI TRACING OPTIONS --------------------------------- +# Do not remove, this variable may be used by user code (e.g. StarPU) +export SMPI_GLOBAL_SIZE=${NUMPROCS} if [ -n "${KEEP}" ] ; then echo ${EXEC} ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP} if [ ${HOSTFILETMP} = 1 ] ; then @@ -524,7 +546,7 @@ fi # * The job is launched in the background in order to be able to handle signals. # # * 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. +# is launched in the background: this can be overridden in bash but not in standard bourne shell. exec 3<&0 ${WRAPPER} "@SMPIMAIN@" ${EXEC} ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP} <&3 3>&- & pid=$! @@ -542,7 +564,7 @@ pid="" # Keep temporary files on failures to help debugging # if [ ${status} -ne 0 ] ; then - if [ -z "${KEEP}" ]; then + if [ -z "${KEEP}" -a -z "${QUIET}" ]; then echo ${EXEC} ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP} if [ ${HOSTFILETMP} = 1 ] ; then echo "Generated hostfile ${HOSTFILE} kept." @@ -550,9 +572,9 @@ if [ ${status} -ne 0 ] ; then if [ ${UNROLLEDHOSTFILETMP} = 1 ] ; then echo "Generated unrolled hostfile ${UNROLLEDHOSTFILE} kept." fi + KEEP=true fi echo "Execution failed with code ${status}." - KEEP=true fi smpirun_cleanup