Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Useless test; TODO--.
[simgrid.git] / src / smpi / smpirun.in
index 245881d..ac3e393 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env sh
 
-# Copyright (c) 2007-2020. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2021. 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.
@@ -14,7 +14,6 @@ DEFAULT_LOOPBACK_BANDWIDTH="498000000Bps"
 DEFAULT_LOOPBACK_LATENCY="0.000004s"
 DEFAULT_NETWORK_BANDWIDTH="$((26 * 1024 * 1024))Bps"
 DEFAULT_NETWORK_LATENCY="0.000005s"
-DEFAULT_NUMPROCS="4"
 DEFAULT_SPEED="100flops"
 
 LOOPBACK_BANDWIDTH="${DEFAULT_LOOPBACK_BANDWIDTH}"
@@ -27,12 +26,15 @@ PRIVATIZE="--cfg=smpi/privatization:${SMPI_PRIVATIZATION:-@HAVE_PRIVATIZATION@}"
 
 SIMOPTS="--cfg=surf/precision:1e-9 --cfg=network/model:SMPI"
 
+SMPITMPDIR="$(dirname $(mktemp -u))"
+
 #usage to print the way this script should be called
 usage () {
     cat <<EOF
 Usage: $0 [OPTIONS] -platform <xmldesc> -hostfile <hostfile> program [program-options]
        $0 [OPTIONS] -platform <xmldesc> -hostfile <hostfile> -replay <tracefile> [program] [program-options]
 Options:
+  -analyze                   # show information about allocations and timings at the end of execution
   -keep-temps                # don't remove the generated files after execution
   -wrapper <command>         # use command to run the program (e.g. "valgrind" or "gdb --args")
   -gdb                       # run within GDB (-wrapper "gdb --args" -keep-temps)
@@ -42,6 +44,7 @@ Options:
   -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
+  -tmpdir                    # Directory used to store temporary files. Defaults to system's. 
   -trace-ti                  # activate time independent 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
@@ -117,7 +120,7 @@ smpirun_trap() {
   unset pid
 
   # Raise the same signal again (remove the traps first):
-  trap - "$trapped_signals"
+  trap - $trapped_signals
   kill -"$sig" $$
 
   # This should never happen:
@@ -126,7 +129,7 @@ smpirun_trap() {
 }
 
 for s in $trapped_signals; do
-  trap 'smpirun_trap $s' "$s"
+  trap "smpirun_trap $s" "$s"
 done
 
 while true; do
@@ -144,29 +147,33 @@ while true; do
             shift 2
             ;;
         "-platform")
-           PLATFORM="$2"
+            PLATFORM="$2"
             if [ ! -f "${PLATFORM}" ]; then
                 die "the file '${PLATFORM}' does not exist"
             fi
-           shift 2
+            shift 2
             ;;
         "-hostfile" | "-machinefile")
-           HOSTFILE="$2"
+            HOSTFILE="$2"
             if [ ! -f "${HOSTFILE}" ]; then
                 die "the file '${HOSTFILE}' does not exist"
             fi
-           shift 2
+            shift 2
             ;;
         "-replay")
             APP_TRACES="$2"
             shift 2
             ;;
-       "-no-privatize")
-           PRIVATIZE="--cfg=smpi/privatization:no"
-           shift 1
-           ;;
+        "-no-privatize")
+            PRIVATIZE="--cfg=smpi/privatization:no"
+            shift 1
+            ;;
         "-map")
-           MAPOPT=1
+            MAPOPT=1
+            shift 1
+            ;;
+        "-tmpdir")
+            SMPITMPDIR="$2"
             shift 1
             ;;
         "-trace")
@@ -203,10 +210,10 @@ while true; do
             SIMOPTS="$SIMOPTS --cfg=smpi/keep-temps:yes"
             shift 1
             ;;
-       "-quiet")
-           QUIET="true"
-           shift 1
-           ;;
+        "-quiet")
+            QUIET="true"
+            shift 1
+            ;;
         "-wrapper")
             WRAPPER="$2"
             shift 2
@@ -229,6 +236,10 @@ while true; do
             SIMOPTS="$SIMOPTS --cfg=smpi/keep-temps:yes"
             shift 1
             ;;
+        "-analyze")
+            SIMOPTS="$SIMOPTS --cfg=smpi/display-timing:yes --cfg=smpi/display-allocs:yes --cfg=smpi/list-leaks:50"
+            shift 1
+            ;;
         "-help" | "--help" | "-h")
             usage
             exit 0
@@ -258,6 +269,10 @@ while true; do
     esac
 done
 
+#setup tmp dir
+SIMOPTS="$SIMOPTS --cfg=smpi/tmpdir:$SMPITMPDIR"
+export LD_LIBRARY_PATH="$SMPITMPDIR:$LD_LIBRARY_PATH"
+
 if [ -n "${APP_TRACES}" ] ; then
     if [ $# -eq 0 ] ; then
         EXEC="@SMPIREPLAYMAIN@"
@@ -455,7 +470,7 @@ else
     done
 fi
 
-set -- "$hostnames"
+set -- $hostnames
 
 ##---- generate <actor> tags------------------------------
 #prepare arguments at once
@@ -473,21 +488,24 @@ do
     if [ ${MAPOPT} = 1 ]; then
       echo "[rank $i] -> $host"
     fi
-
+    {
     echo "  <actor host=\"${host}\" function=\"$i\"> <!-- function name used only for logging -->
     <prop id=\"instance_id\" value=\"smpirun\"/>
-    <prop id=\"rank\" value=\"$i\"/>" >> "${APPLICATIONTMP}"
+    <prop id=\"rank\" value=\"$i\"/>"
     if [ ${REPLAY} = 1 ]; then
-        echo "    <prop id=\"smpi_replay\" value=\"true\"/>" >> "${APPLICATIONTMP}"
+        echo "    <prop id=\"smpi_replay\" value=\"true\"/>"
         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}"
+           # Give each process its trace file (as an argument)
+            echo "    <argument value=\"$(echo "$hosttraces"|cut -d' ' -f$j)\"/>"
+        elif [ ${i} = 0 ]; then
+           # Give the shared trace file to rank 0 (as a property)
+            echo "    <prop id=\"tracefile\" value=\"$(echo "$hosttraces"|cut -d' ' -f1)\"/>"
         fi
     else
-    echo "${XML_ARGS}" >> "${APPLICATIONTMP}"
+    echo "${XML_ARGS}"
     fi
-    echo "  </actor>" >> "${APPLICATIONTMP}"
+    echo "  </actor>"
+    }    >> "${APPLICATIONTMP}"
 done
 
 cat >> "${APPLICATIONTMP}" <<APPLICATIONFOOT
@@ -550,7 +568,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 overridden in bash but not in standard bourne shell.
 exec 3<&0
-${WRAPPER} "@SMPIMAIN@" "${EXEC}" ${PRIVATIZE} "${TRACEOPTIONS}" "${SIMOPTS}" "${PLATFORMTMP}" "${APPLICATIONTMP}" <&3 3>&- &
+${WRAPPER} "@SMPIMAIN@" "${EXEC}" ${PRIVATIZE} ${TRACEOPTIONS} ${SIMOPTS} "${PLATFORMTMP}" "${APPLICATIONTMP}" <&3 3>&- &
 pid=$!
 exec 3>&-
 wait $pid