Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
smpirun: report exit status.
[simgrid.git] / src / smpi / smpirun.in
index 07c97f7..4bc0c03 100755 (executable)
@@ -16,13 +16,18 @@ NETWORK_LATENCY="${DEFAULT_NETWORK_LATENCY}"
 NUMPROCS="${DEFAULT_NUMPROCS}"
 POWER="${DEFAULT_POWER}"
 
-SIMOPTS="--cfg=maxmin/precision:1e-9 --cfg=network/model:SMPI --cfg=TCP_gamma:4194304"
-
+SIMOPTS="--cfg=maxmin/precision:1e-9 --cfg=network/model:SMPI --cfg=network/TCP_gamma:4194304"
 
 #usage to print the way this script should be called
 function usage () {
     echo "usage:"
-    echo "$0 [-quiet] [-keep-temps] [-trace <tracefile>] [-np <numprocs>] -platform <xmldesc> -hostfile <hostfile> [-map] program [program-options]"
+    echo "$0 [-quiet] [-keep-temps]"
+    echo "      [-np <numprocs>] -platform <xmldesc> -hostfile <hostfile> [-map] program [program-options]"
+    echo "      [-trace]                  # activate tracing"
+    echo "      [-trace-grouped]          # group MPI processes by location"
+    echo "      [-trace-resource]         # trace resource utilization"
+    echo "      [-trace-triva]            # generate configuration for Triva's GraphView"
+    echo "      [-trace-file <tracefile>] # name of the tracefile (simgrid_smpi.trace)"
     echo "or (deprecated usage):"
     echo "$0 [-quiet] [-keep-temps] [-np <numprocs>] [-bandwidth <bytes/sec>] [-latency <secs>] program [program-options]"
     echo
@@ -35,7 +40,6 @@ then
     exit
 fi
 
-
 while true; do
   case "$1" in
    "-np" | "-n")
@@ -73,17 +77,27 @@ while true; do
    ;;
 
    "-trace")
-       TRACEOPT="$2"
-         shift 2
+       TRACE_ACTIVE="true"
+         shift 1
+   ;;
+
+   "-trace-file")
+      TRACE_FILENAME="$2"
+      shift 2
    ;;
 
    "-trace-grouped")
-    TRACE_GROUPED="true"
+      TRACE_GROUPED="true"
       shift 1
    ;;
 
-   "-triva")
-       TRIVA="true"
+   "-trace-resource")
+      TRACE_RESOURCE="true"
+      shift 1
+   ;;
+
+   "-trace-triva")
+       TRACE_TRIVA="true"
          shift 1
    ;;
 
@@ -115,6 +129,13 @@ shift
 
 ##-----------------------------------
 
+# test if we have something to execute, otherwise show usage and exit
+if [ -z ${EXEC} ]
+then
+    echo "Program is missing"
+    usage
+    exit 1
+fi
 
 
 
@@ -208,7 +229,7 @@ do
   else
        host="${hostnames[$j]}"
   fi
-  echo "  <process host=\"${host}\" function=\"smpi_simulated_main\">" >> ${APPLICATIONTMP}
+  echo "  <process host=\"${host}\" function=\"rank$i\"> <!-- function name used only for logging -->" >> ${APPLICATIONTMP}
   echo "    <argument value=\"$i\"/> <!-- rank -->" >> ${APPLICATIONTMP}
   for ARG in $*; do
     echo "    <argument value=\"${ARG}\"/>" >> ${APPLICATIONTMP}
@@ -222,19 +243,25 @@ APPLICATIONFOOT
 ##-------------------------------- end DEFAULT APPLICATION --------------------------------------
 
 ##---------------------- SMPI TRACING OPTIONS ---------------------------------
-  if [ -n "${TRACEOPT}" ]; then
-    TRACEOPTIONS="--cfg=tracing:1 --cfg=tracing/filename:${TRACEOPT} --cfg=tracing/smpi:1 --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1"
-  else
-    TRACEOPTIONS=""
+if [ -n "${TRACE_ACTIVE}" ]; then
+  #define trace filename
+  if [ -z "${TRACE_FILENAME}" ]; then
+    TRACE_FILENAME="smpi_simgrid.trace"
   fi
+  TRACEOPTIONS="--cfg=tracing:1 --cfg=tracing/filename:${TRACE_FILENAME} --cfg=tracing/smpi:1"
 
-  if [ -n "${TRIVA}" ]; then
-    TRACEOPTIONS="$TRACEOPTIONS --cfg=triva/categorized:smpi_cat.plist --cfg=triva/uncategorized:smpi_uncat.plist"
+  if [ -n "${TRACE_GROUPED}" ]; then
+    TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/smpi/group:1"
   fi
 
-  if [ -n "${TRACE_GROUPED}" ]; then
-    TRACEOPTIONS="$TRACEOPTIONS --cfg=tracing/smpi/group:1"
+  if [ -n "${TRACE_RESOURCE}" ]; then
+    TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1"
   fi
+
+  if [ -n "${TRACE_TRIVA}" ]; then
+    TRACEOPTIONS="${TRACEOPTIONS} --cfg=triva/categorized:smpi_cat.plist --cfg=triva/uncategorized:smpi_uncat.plist"
+  fi
+fi
 ##---------------------- end SMPI TRACING OPTIONS ---------------------------------
 
 export SMPI_GLOBAL_SIZE=${NUMPROCS}
@@ -242,6 +269,7 @@ if [ -n "${KEEP}" ] ; then
   echo ${EXEC} ${SIMOPTS} ${TRACEOPTIONS} ${PLATFORMTMP} ${APPLICATIONTMP}
 fi
 ${EXEC} ${SIMOPTS} ${TRACEOPTIONS} ${PLATFORMTMP} ${APPLICATIONTMP}
+status=$?
 
 if [ -z "${KEEP}" ] ; then
    if [ -z "${PLATFORM}" ]; then
@@ -249,3 +277,5 @@ if [ -z "${KEEP}" ] ; then
    fi
    rm ${APPLICATIONTMP}
 fi
+
+exit $status