Browse Source

tools: put temp files in directory where input file is

Nathalie Furmento 4 years ago
parent
commit
116117fa22

+ 18 - 17
tools/starpu_paje_draw_histogram.in

@@ -20,7 +20,6 @@
 set -e # fail fast
 
 # File names
-basename="$PWD"
 r_script="$(dirname $(which $0))/starpu_paje_draw_histogram.R"
 r_input=""
 
@@ -107,24 +106,32 @@ for file in $inputfiles; do
 	echo "Error: file $file does not exist!"
 	exit 5
     fi
-# Sorting traces
-    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' $file > start.trace
-    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' -v $file > end.trace
-    sort -s -V --key=2,2 end.trace > endSorted.trace
-    if grep -q start_profiling endSorted.trace
+    dir=$(dirname $file)
+    # Sorting traces
+    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' $file > $dir/start.trace
+    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' -v $file > $dir/end.trace
+    sort -s -V --key=2,2 $dir/end.trace > $dir/endSorted.trace
+    if grep -q start_profiling $dir/endSorted.trace
     then
 	echo Using start_profiling/stop_profiling trace selection.
-	sed -ne '/start_profiling/,/stop_profiling/p' < endSorted.trace > endSorted2.trace
+	sed -ne '/start_profiling/,/stop_profiling/p' < $dir/endSorted.trace > $dir/endSorted2.trace
     else
-	cp endSorted.trace endSorted2.trace
+	cp $dir/endSorted.trace $dir/endSorted2.trace
     fi
-    cat start.trace endSorted2.trace > outputSorted.trace
+    cat $dir/start.trace $dir/endSorted2.trace > $dir/outputSorted.trace
 
-# Transferring to .csv
-    pj_dump -n outputSorted.trace > $file.csv
+    # Transferring to .csv
+    pj_dump -n $dir/outputSorted.trace > $file.csv
     perl -i -ne 'print if /^State/' $file.csv
 
     r_input=$(eval echo "$r_input $file.csv")
+
+    # Cleanup: delete temporary files
+    rm -f $dir/outputSorted.trace
+    rm -f $dir/start.trace
+    rm -f $dir/end.trace
+    rm -f $dir/endSorted.trace
+    rm -f $dir/endSorted2.trace
 done
 
 #####################################
@@ -136,9 +143,3 @@ if [[ $verbose == 1 ]]; then
     evince Rplots.pdf
 fi
 
-# Cleanup: delete temporary files
-rm -f outputSorted.trace
-rm -f start.trace
-rm -f end.trace
-rm -f endSorted.trace
-rm -f endSorted2.trace

+ 15 - 17
tools/starpu_paje_sort.in

@@ -19,9 +19,6 @@
 
 set -e # fail fast
 
-# File names
-basename="$PWD"
-
 inputfiles=""
 
 help_script()
@@ -87,6 +84,7 @@ for file in $inputfiles; do
 	echo "Error: file $file does not exist!"
 	exit 5
     fi
+    dir=$(dirname $file)
     DefCont="$(get_event_num $file PajeDefineContainerType) "
     DefEvent="$(get_event_num $file PajeDefineEventType) "
     DefState="$(get_event_num $file PajeDefineStateType) "
@@ -97,22 +95,22 @@ for file in $inputfiles; do
     AddVar="$(get_event_num $file PajeAddVariable) "
     grepstr="^\\(%\\|$DefCont\\|$DefEvent\\|$DefState\\|$DefVar\\|$DefLink\\|$DefEnt\\|$CreateCont\\|$AddVar\\)"
     grepstr=${grepstr//[ 	]/[ 	]}
-# Sorting traces
-    grep -e "$grepstr" $file > start.trace
-    grep -e "$grepstr" -v $file > end.trace
-    sort -s -V --key=2,2 end.trace > endSorted.trace
-    if grep -q start_profiling endSorted.trace
+    # Sorting traces
+    grep -e "$grepstr" $file > $dir/start.trace
+    grep -e "$grepstr" -v $file > $dir/end.trace
+    sort -s -V --key=2,2 $dir/end.trace > $dir/endSorted.trace
+    if grep -q start_profiling $dir/endSorted.trace
     then
 	echo Using start_profiling/stop_profiling trace selection.
-	sed -ne '/start_profiling/,/stop_profiling/p' < endSorted.trace > endSorted2.trace
+	sed -ne '/start_profiling/,/stop_profiling/p' < $dir/endSorted.trace > $dir/endSorted2.trace
     else
-	cp endSorted.trace endSorted2.trace
+	cp $dir/endSorted.trace $dir/endSorted2.trace
     fi
-    cat start.trace endSorted2.trace > $file
-done
+    cat $dir/start.trace $dir/endSorted2.trace > $file
 
-# Cleanup: delete temporary files
-rm -f start.trace
-rm -f end.trace
-rm -f endSorted.trace
-rm -f endSorted2.trace
+    # Cleanup: delete temporary files
+    rm -f $dir/start.trace
+    rm -f $dir/end.trace
+    rm -f $dir/endSorted.trace
+    rm -f $dir/endSorted2.trace
+done

+ 18 - 17
tools/starpu_paje_state_stats.in

@@ -20,7 +20,6 @@
 set -e # fail fast
 
 # File names
-basename="$PWD"
 outputfile="starpu_paje_state_stats.csv"
 r_script="$(dirname $(which $0))/starpu_paje_state_stats.R"
 r_input=""
@@ -108,24 +107,32 @@ for file in $inputfiles; do
 	echo "Error: file $file does not exist!"
 	exit 5
     fi
-# Sorting traces
-    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' $file > start.trace
-    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' -v $file > end.trace
-    sort -s -V --key=2,2 end.trace > endSorted.trace
-    if grep -q start_profiling endSorted.trace
+    dir=$(dirname $file)
+    # Sorting traces
+    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' $file > $dir/start.trace
+    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' -v $file > $dir/end.trace
+    sort -s -V --key=2,2 $dir/end.trace > $dir/endSorted.trace
+    if grep -q start_profiling $dir/endSorted.trace
     then
 	echo Using start_profiling/stop_profiling trace selection.
-	sed -ne '/start_profiling/,/stop_profiling/p' < endSorted.trace > endSorted2.trace
+	sed -ne '/start_profiling/,/stop_profiling/p' < $dir/endSorted.trace > $dir/endSorted2.trace
     else
-	cp endSorted.trace endSorted2.trace
+	cp $dir/endSorted.trace $dir/endSorted2.trace
     fi
-    cat start.trace endSorted2.trace > outputSorted.trace
+    cat $dir/start.trace $dir/endSorted2.trace > $dir/outputSorted.trace
 
-# Transferring to .csv
-    pj_dump -n outputSorted.trace > $file.csv
+    # Transferring to .csv
+    pj_dump -n $dir/outputSorted.trace > $file.csv
     perl -i -ne 'print if /^State/' $file.csv
 
     r_input=$(eval echo "$r_input $file.csv")
+
+    # Cleanup: delete temporary files
+    rm -f $dir/outputSorted.trace
+    rm -f $dir/start.trace
+    rm -f $dir/end.trace
+    rm -f $dir/endSorted.trace
+    rm -f $dir/endSorted2.trace
 done
 
 #####################################
@@ -137,9 +144,3 @@ if [[ $verbose == 1 ]]; then
     column -s, -t $outputfile
 fi
 
-# Cleanup: delete temporary files
-rm -f outputSorted.trace
-rm -f start.trace
-rm -f end.trace
-rm -f endSorted.trace
-rm -f endSorted2.trace

+ 15 - 13
tools/starpu_paje_summary.in

@@ -83,15 +83,22 @@ for file in $inputfiles; do
 	echo "Error: file $file does not exist!"
 	exit 5
     fi
-# Sorting traces
-    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\)\>\)\)' $file > start.trace
-    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\|18\|19\)\>\)\)' -v  $file > end.trace
-    sort -s -V --key=2,2 end.trace > endSorted.trace
-    cat start.trace endSorted.trace > outputSorted.trace
-
-# Transferring to .csv
-    pj_dump -n outputSorted.trace > $file.csv
+    dir=$(dirname $file)
+    # Sorting traces
+    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\)\>\)\)' $file > $dir/start.trace
+    grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\|18\|19\)\>\)\)' -v  $file > $dir/end.trace
+    sort -s -V --key=2,2 $dir/end.trace > $dir/endSorted.trace
+    cat $dir/start.trace $dir/endSorted.trace > $dir/outputSorted.trace
+
+    # Transferring to .csv
+    pj_dump -n $dir/outputSorted.trace > $file.csv
     perl -i -ne 'print if /^State/' $file.csv
+
+    # Cleanup: delete temporary files
+    rm -f $dir/outputSorted.trace
+    rm -f $dir/start.trace
+    rm -f $dir/end.trace
+    rm -f $dir/endSorted.trace
 done
 
 analysis_input=`echo \"$inputfiles".csv\"" | sed 's/  */.csv", "/g'`
@@ -102,8 +109,3 @@ Rscript -e "library(knitr); input_traces = c($analysis_input) ; outputhtml='$out
             outputRmd = gsub('.html\$','.Rmd',outputhtml);\
             knit('$analysis_script',output=outputRmd); knitr::knit2html(outputRmd)"
 
-# Cleanup: delete temporary files
-rm -f outputSorted.trace
-rm -f start.trace
-rm -f end.trace
-rm -f endSorted.trace