source: CIVL/examples/omp/dataracebench-1.3.2/micro-benchmarks/utilities/time_benchmark.sh@ bb03188

main test-branch
Last change on this file since bb03188 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100755
File size: 2.8 KB
Line 
1#!/bin/sh
2## time_benchmark.sh for in /Users/pouchet
3##
4## Made by Louis-Noel Pouchet
5## Contact: <pouchet@cse.ohio-state.edu>
6## License: /LICENSE.OSU.txt
7##
8## Started on Sat Oct 29 00:03:48 2011 Louis-Noel Pouchet
9## Last update Sat Oct 29 01:16:34 2011 Louis-Noel Pouchet
10##
11
12## Maximal variance accepted between the 3 median runs for performance results.
13## Here 5%
14VARIANCE_ACCEPTED=5;
15
16if [ $# -ne 1 ]; then
17 echo "Usage: ./time_benchmarh.sh <binary_name>";
18 echo "Example: ./time_benchmarh.sh \"./a.out\"";
19 echo "Note: the file must be a Polybench program compiled with -DPOLYBENCH_TIME";
20 exit 1;
21fi;
22
23
24compute_mean_exec_time()
25{
26 file="$1";
27 benchcomputed="$2";
28 cat "$file" | grep "[0-9]\+" | sort -n | head -n 4 | tail -n 3 > avg.out;
29 expr="(0";
30 while read n; do
31 expr="$expr+$n";
32 done < avg.out;
33 time=`echo "scale=8;$expr)/3" | bc`;
34 tmp=`echo "$time" | cut -d '.' -f 1`;
35 if [ -z "$tmp" ]; then
36 time="0$time";
37 fi;
38 val1=`cat avg.out | head -n 1`;
39 val2=`cat avg.out | head -n 2 | tail -n 1`;
40 val3=`cat avg.out | head -n 3 | tail -n 1`;
41 val11=`echo "a=$val1 - $time;if(0>a)a*=-1;a" | bc 2>&1`;
42 test_err=`echo "$val11" | grep error`;
43 if ! [ -z "$test_err" ]; then
44 echo "[ERROR] Program output does not match expected single-line with time.";
45 echo "[ERROR] The program must be a PolyBench, compiled with -DPOLYBENCH_TIME";
46 exit 1;
47 fi;
48 val12=`echo "a=$val2 - $time;if(0>a)a*=-1;a" | bc`;
49 val13=`echo "a=$val3 - $time;if(0>a)a*=-1;a" | bc`;
50 myvar=`echo "$val11 $val12 $val13" | awk '{ if ($1 > $2) { if ($1 > $3) print $1; else print $3; } else { if ($2 > $3) print $2; else print $3; } }'`;
51 variance=`echo "scale=5;($myvar/$time)*100" | bc`;
52 tmp=`echo "$variance" | cut -d '.' -f 1`;
53 if [ -z "$tmp" ]; then
54 variance="0$variance";
55 fi;
56 compvar=`echo "$variance $VARIANCE_ACCEPTED" | awk '{ if ($1 < $2) print "ok"; else print "error"; }'`;
57 if [ "$compvar" = "error" ]; then
58 $ECHO_CMD "\033[31m[WARNING]\033[0m Variance is above thresold, unsafe performance measurement";
59 $ECHO_CMD " => max deviation=$variance%, tolerance=$VARIANCE_ACCEPTED%";
60 WARNING_VARIANCE="$WARNING_VARIANCE\n$benchcomputed: max deviation=$variance%, tolerance=$VARIANCE_ACCEPTED%";
61 else
62 echo "[INFO] Maximal deviation from arithmetic mean of 3 average runs: $variance%";
63 fi;
64 PROCESSED_TIME="$time";
65 rm -f avg.out;
66}
67
68echo "[INFO] Running 5 times $1..."
69echo "[INFO] Maximal variance authorized on 3 average runs: $VARIANCE_ACCEPTED%)...";
70
71$1 > ____tempfile.data.polybench;
72$1 >> ____tempfile.data.polybench;
73$1 >> ____tempfile.data.polybench;
74$1 >> ____tempfile.data.polybench;
75$1 >> ____tempfile.data.polybench;
76
77compute_mean_exec_time "____tempfile.data.polybench" "$1";
78echo "[INFO] Normalized time: $PROCESSED_TIME";
79rm -f ____tempfile.data.polybench;
Note: See TracBrowser for help on using the repository browser.