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

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