Parcourir la source

SCRIPTS: Added power measurement in the timing script

Now the time-and-save script handle the power measurement through the
SmartPower utility. We also added an additional SIGKILL on the
measurement process to avoid zombie processes hanging around when the
data retrieval fails.
Andrea Gussoni il y a 8 ans
Parent
commit
d4fe244c5f
1 fichiers modifiés avec 26 ajouts et 2 suppressions
  1. 26 2
      utils/time-and-save.sh

+ 26 - 2
utils/time-and-save.sh

@@ -3,6 +3,7 @@
 # Save path the current path that will be used to store the results.
 BASE_PATH=$(pwd)
 
+
 # Local variable to store if cpu or gpu directed benchmark
 TYPE=$3
 
@@ -15,15 +16,38 @@ if [ ! -d "results/$TYPE" ]; then
     mkdir results/$TYPE
 fi
 
+
+# Start power measurement
+./SmartPower results/$TYPE/power-usage.csv & export PID_POWER=$!
+echo $PID_POWER
+
+
 # Enter in the directory passed as first parameter, then execute run and save the results in the file passed as second parameter
 cd $1
 BENCH_NAME=$1
 
-# Start the actual benchmark
+# Start and time the actual benchmark
 BENCH_TIME=`(/usr/bin/time -f "%e" ./run-$TYPE) 2>&1 > /dev/zero | tail -1`
 
+# Stop power measurement
+kill -SIGUSR1 $PID_POWER
+
+# Add an additional SIGKILL to avoid zombie processes in case of a faulty measurement
+kill -SIGKILL $PID_POWER
+
+# Wait until the Smartpower utility has received the kill signal and force a sync on the disk to avoid reading the previous result
+
+sleep 5 && sync
+
+
 # Save execution time in the log
 echo "$BENCH_NAME $BENCH_TIME" >> $BASE_PATH/results/$TYPE/$2
 
+# Prepare a log that contains all the info relative to a benchmark
+# To retrieve the power measurement we take the third column of the last row from the file where the measurement utility has saved the results
+BENCH_CONSUMPTION=`tail -1 $BASE_PATH/results/$TYPE/power-usage.csv | awk '{print $3}' | cut -d, -f2`
+echo "$BENCH_NAME $BENCH_TIME $BENCH_CONSUMPTION" >> $BASE_PATH/results/$TYPE/total.dat
+
+
 # Sleep in order to give time to the power measurement script to reset.
-sleep 5
+sleep 3