-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOLE_eval_entity_vsO0.sh
executable file
·76 lines (68 loc) · 2.21 KB
/
COLE_eval_entity_vsO0.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Example evaluation script for COLE.
# (see https://github.com/kehoste/COLE)
#
# $COLE_OPTFLAGS is set by COLE with optimization flags to use
#
# (only) evaluation result is printed to stdout, prefixed by 'Just'
# 'Nothing' is printed in case compilation or execution failed
#
# progress of evaluation script is printed to stderr (ignored by COLE)
if [ -z "$COLE_OPTFLAGS" ]
then
echo "Environment variable COLE_OPTFLAGS not found!"
exit 1
fi
benchmark="n-body"
#param=5000000
param=500000
# fetch evaluation result for O0
base_result_file=COLE_base_result_${benchmark}-${param}.txt
if [ -f $base_result_file ] || [ "$COLE_OPTFLAGS" == "-O0" ]
then
if [ "$COLE_OPTFLAGS" != "-O0" ]
then
# fetch base result
base_comp_time=`cat $base_result_file | sed 's/Just (\([0-9.]*\),[0-9.]*)/\1/g'`
base_exec_time=`cat $base_result_file | sed 's/Just ([0-9.]*,\([0-9.]*\))/\1/g'`
fi
else
# this will make COLE crash due to a parsing error -- good!
echo "Base result is missing! (see $base_result_file)"
exit 1
fi
# compile benchmark using given flags
echo -n "... compiling " 1>&2
/usr/bin/time -f "%e" ghc -fforce-recomp --make -XBangPatterns $COLE_OPTFLAGS $benchmark &> /tmp/comp.out
if [ $? -eq 0 ]
then
comp_time=`cat /tmp/comp.out | egrep -v "] Compiling|Linking"`
# execute compiled benchmark
echo -n "(comp. time: $comp_time) ... executing $benchmark $param " 1>&2
exec_time=`/usr/bin/time -f "%e" ./$benchmark $param 2>&1 > /dev/null`
if [ $? -eq 0 ]
then
# cleanup
rm -f $benchmark ${benchmark}.hi ${benchmark}.o
echo "(exec. time: $exec_time) ... DONE!" 1>&2
# return results
if [ "$COLE_OPTFLAGS" == "-O0" ]
then
echo "Just ($comp_time,$exec_time)"
else
comp_cost=`echo "$base_comp_time $comp_time" | awk '{print $2/$1;}'`
speedup=`echo "$base_exec_time $exec_time" | awk '{print $1/$2;}'`
echo "Just ($comp_cost,$speedup)"
fi
else
# execution failed => no result
echo "Execution failed: $exec_time" 1>&2
echo "Nothing"
fi
else
# compilation failed => no result
echo "Compilation failed: " 1>&2
cat /tmp/comp.out 1>&2
echo "Nothing"
fi
rm -f /tmp/comp.out