Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more bash->sh changes
[simgrid.git] / src / smpi / smpirun.in
index a5f406f..db5e7e7 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 @CMAKE_SMPI_COMMAND@
 
@@ -27,7 +27,8 @@ Options:
   -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.
-  -trace                     # activate tracing
+  -trace-ti                  # activate time independant 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
   -trace-comment-file <file> # put file contents on the top of the trace file as comment
   -trace-grouped             # group MPI processes by location
@@ -98,6 +99,12 @@ while true; do
       shift 1
    ;;
 
+   "-trace-ti")
+      TRACE_ACTIVE="true"
+      TRACE_TI_ACTIVE="true"
+      shift 1
+   ;;
+
    "-trace-comment")
       TRACE_COMMENT="$2"
       shift 2
@@ -174,7 +181,7 @@ while [ $# -gt 0 ]; do
      shift 1
    ;;
     *)
-      PROC_ARGS="$PROC_ARGS $1"
+      PROC_ARGS="${PROC_ARGS:+$PROC_ARGS }$1"
       shift      
     ;;
   esac
@@ -190,12 +197,19 @@ if [ -z "${EXEC}" ] ; then
     exit 1
 fi
 
-if [ -z "${HOSTFILE}" ] ; then
-    echo "No hostfile specified."
+if [ -z "${HOSTFILE}" ] && [ -z "${PLATFORM}" ] ; then
+    echo "No hostfile nor platform specified."
     usage
     exit 1
 fi
 
+HOSTFILETMP=0
+if [ -z "${HOSTFILE}" ] ; then
+    HOSTFILETMP=1
+    HOSTFILE="$(mktemp tmphostXXXXXX)"
+    perl -ne 'print "$1\n" if /.*<host.*?id="(.*?)".*?\/>.*/' ${PLATFORM} > ${HOSTFILE}
+fi
+
 # Don't use wc -l to compute it to avoid issues with trailing \n at EOF
 hostfile_procs=`grep -c "[a-zA-Z0-9]" $HOSTFILE`
 
@@ -264,7 +278,7 @@ if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
 fi
 
 if [ "${EXTOPT}" = "smpi_replay" ]; then
-  APP_TRACES=$1;
+  APP_TRACES=$PROC_ARGS
   if [ -n "${APP_TRACES}" ] && [ -f "${APP_TRACES}" ]; then
      hosttraces=(`cat ${APP_TRACES} | tr \\\n " "`)
      NUMTRACES=`cat ${APP_TRACES} | wc -l`
@@ -334,10 +348,17 @@ APPLICATIONFOOT
 ##---------------------- SMPI TRACING OPTIONS ---------------------------------
 if [ -n "${TRACE_ACTIVE}" ]; then
   #define trace filename
-  if [ -z "${TRACE_FILENAME}" ]; then
-    TRACE_FILENAME="smpi_simgrid.trace"
+  if [ -n "${TRACE_TI_ACTIVE}" ]; then
+    if [ -z "${TRACE_FILENAME}" ]; then
+      TRACE_FILENAME="smpi_simgrid.txt"
+    fi
+    TRACEOPTIONS="--cfg=tracing:yes --cfg=tracing/filename:${TRACE_FILENAME} --cfg=tracing/smpi:yes --cfg=tracing/smpi/format:TI --cfg=tracing/smpi/computing:yes"
+  else
+    if [ -z "${TRACE_FILENAME}" ]; then
+      TRACE_FILENAME="smpi_simgrid.trace"
+    fi
+    TRACEOPTIONS="--cfg=tracing:yes --cfg=tracing/filename:${TRACE_FILENAME} --cfg=tracing/smpi:yes"
   fi
-  TRACEOPTIONS="--cfg=tracing:1 --cfg=tracing/filename:${TRACE_FILENAME} --cfg=tracing/smpi:1"
 
   if [ -n "${TRACE_COMMENT}" ]; then
     TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/comment:${TRACE_COMMENT}"
@@ -348,11 +369,11 @@ if [ -n "${TRACE_ACTIVE}" ]; then
   fi
 
   if [ -n "${TRACE_GROUPED}" ]; then
-    TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/smpi/group:1"
+    TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/smpi/group:yes"
   fi
 
   if [ -n "${TRACE_RESOURCE}" ]; then
-    TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/categorized:1 --cfg=tracing/uncategorized:1"
+    TRACEOPTIONS="${TRACEOPTIONS} --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes"
   fi
 
   if [ -n "${TRACE_VIVA}" ]; then
@@ -364,6 +385,9 @@ fi
 export SMPI_GLOBAL_SIZE=${NUMPROCS}
 if [ -n "${KEEP}" ] ; then
   echo ${EXEC} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP}
+  if [ ${HOSTFILETMP} = 1 ] ; then
+    echo "Generated hostfile ${HOSTFILE} keeped."
+  fi
 fi
 ${EXEC} ${TRACEOPTIONS} ${SIMOPTS} ${PLATFORMTMP} ${APPLICATIONTMP}
 status=$?
@@ -372,6 +396,9 @@ if [ -z "${KEEP}" ] ; then
    if [ -z "${PLATFORM}" ]; then
        rm ${PLATFORMTMP}
    fi
+   if [ ${HOSTFILETMP} = 1 ] ; then
+        rm ${HOSTFILE}
+   fi
    rm ${APPLICATIONTMP}
 fi