Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
More doc [skip ci]
[simgrid.git] / src / smpi / smpirun.in
index 9e5689e..ac444b7 100755 (executable)
@@ -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 <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.
@@ -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
@@ -420,7 +424,7 @@ 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
@@ -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,7 +510,7 @@ 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
@@ -517,7 +521,7 @@ pid=""
 #
 if [ ${status} -ne 0 ] ; then
     if [ -z ${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