]> AND Private Git Repository - loba.git/blobdiff - Experimentations/run-all
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
API change in SimGrid 3.8: MSG_global_init -> MSG_init.
[loba.git] / Experimentations / run-all
index 638c0a5997ba9f7d7d530087351fc4477a011c0b..5b80fbf49f0f40f2491b4bf81aa2f5ab5a327195 100755 (executable)
@@ -10,6 +10,7 @@ Options:
     -h  print this help
     -n  dry-run mode (for debugging)
     -c  (continue) do not overwrite previous results
+    -z  compress output files with gzip
 EOF
     exit $1
 }
@@ -34,11 +35,13 @@ array_check() {
 # read args
 overwrite=1
 debug=0
-while getopts "chn" c; do
+compress=0
+while getopts "chnz" c; do
     case "$c" in
         'c') overwrite=0 ;;
         'h') usage 0 ;;
         'n') debug=1 ;;
+        'z') compress=1 ;;
         '?') usage 1 ;;
     esac
 done
@@ -49,7 +52,7 @@ parameters="$1"
 log "Running: $0 $@"
 log "Hostname: $(hostname -f)"
 
-declare -a TOPOLOGIES ALGORITHMS PLATFORMS COMMON_OPTS MORE_ARGS
+declare -a TOPOLOGIES ALGORITHMS PLATFORMS VARIANTS COMMON_OPTS MORE_ARGS
 
 # read parameters
 log "Reading parameters from \"$1\"."
@@ -63,14 +66,19 @@ variable_check LOAD
 variable_check DEADLINE
 
 # default values
-: ${RESULTS:=$PWD/results}
-: ${LOBA:=$PWD/loba}
+test -n "$VARIANTS" || VARIANTS=( "plain" "bookkeeping" )
+test -n "$RESULTS"  || RESULTS="$PWD/results"
+test -n "$LOBA"     || LOBA="$PWD/loba"
 
 COMMON_OPTS=(
-    --cfg=contexts/factory:raw
     "${MORE_ARGS[@]}"
 )
 
+test -f "$LOBA" && test -x "$LOBA" || die "command not found: \"$LOBA\""
+for plat in "${PLATFORMS[@]}"; do
+    test -f "$plat" && test -r "$plat" || die "file not found: \"$plat\""
+done
+
 log "Results put in: \"$RESULTS\"."
 
 [ $debug = 1 ] && log "Running in dry-run mode"
@@ -80,19 +88,26 @@ outfile() {
 }
 
 summary() {
-    sed -n '\!^\[main/INFO\] ,----\[ Results \]!,${
-      /send\|recv\|wall clock\|Simulation succeeded/d;p;
-    }' "$1"
+    gzip -cdf "$@" \
+    | sed -n '\!^\[main/INFO\] ,----\[ Results \]!,${
+        /send\|recv\|wall clock\|Simulation succeeded/d;p;
+      }'
 }
 
+if [ $compress = 1 ]; then
+    outsuffix=".gz"
+else
+    outsuffix=""
+fi
+
 for plat in "${PLATFORMS[@]}"; do
     tmp=$(basename "$plat" ".xml")
     plat_output="$RESULTS/plat_$tmp"
     for topo in "${TOPOLOGIES[@]}"; do
         topo_output="$plat_output/topo_$topo"
+        [ $debug = 0 ] && mkdir -p "$topo_output"
         for algo in "${ALGORITHMS[@]}"; do
             algo_output="$topo_output/algo_$algo"
-            [ $debug = 0 ] && mkdir -p "$algo_output"
             args=(
                 -T"$topo"
                 -a"$algo"
@@ -101,25 +116,36 @@ for plat in "${PLATFORMS[@]}"; do
                 -t"$DEADLINE"
                 "$plat"
             )
-            for bk in "" "-b"; do
-                tmp=$(outfile "loba" $bk "${args[@]}")
-                out="$algo_output/$tmp.out"
-                cmd=( "$LOBA" "${COMMON_OPTS[@]}" $bk "${args[@]}" )
-                log "Run: ${cmd[@]}"$'\n'"... &> $out"
-                if [ $overwrite = 0 -a -e "$out" ]; then
+            for variant in "${VARIANTS[@]}"; do
+                cmd=( "$LOBA" "${COMMON_OPTS[@]}" )
+                case "$variant" in
+                    "plain") : ;;
+                    "bookkeeping") cmd+=( "-b" ) ;;
+                    *) die "unknown variant: \"$variant\"" ;;
+                esac
+                out="${algo_output}_${variant}.out"
+                outf="$out$outsuffix"
+                cmd+=( "${args[@]}" )
+                log "Run: ${cmd[@]}"$'\n'"... &> $outf"
+                if [ $overwrite = 0 -a -e "$outf" ]; then
                     log "already run !"
-                    summary "$out"
+                    summary "$outf"
                     continue
                 fi
                 if [ $debug = 1 ]; then
                     log "skipped (dry-run)"
+                    continue
+                fi
+                rm -f "$outf";
+                echo "# ${cmd[@]}" > "$out"
+                if "${cmd[@]}" >> "$out" 2>&1; then
+                    summary "$out"
                 else
-                    echo "# ${cmd[@]}" > "$out"
-                    if "${cmd[@]}" >> "$out" 2>&1; then
-                        summary "$out"
-                    else
-                        grep -v '/INFO\]' "$out"
-                    fi
+                    grep -v '/INFO\]' "$out"
+                fi
+                if [ $compress = 1 ]; then
+                    log "Compress output file."
+                    gzip --best "$out"
                 fi
             done
         done