blob: e1b1a929f47e65754e0821993387ef90523943c2 [file] [log] [blame]
bart8785c122008-05-29 08:34:27 +00001#!/bin/bash
2
3########################
4# Function definitions #
5########################
6
7# Read a stream of numbers from stdin (one per line), and print the average
8# and standard deviation.
9function avgstddev {
bartf06b4272008-05-30 09:52:13 +000010 awk '{n++;sum+=$1;sumsq+=$1*$1}END{d=sumsq/n-sum*sum/n/n;print sum/n,(d>0?sqrt(d):0)}'
bart8785c122008-05-29 08:34:27 +000011}
12
13function run_test {
14 local tmp avg1=1 stddev1=1 avg2=1 stddev2=1
15
16 tmp="/tmp/test-timing.$$"
17 echo "$@"
18 for ((i=0;i<3;i++))
19 do
20 /usr/bin/time --format="%e" "$@" 2>&1 | tail -n 1
21 done | avgstddev > "$tmp"
22 read avg1 stddev1 < "$tmp"
23 echo "Average time: ${avg1} +/- ${stddev1} seconds"
24
bartc4a174f2008-06-03 11:41:19 +000025 for ((p=1; p<=4; p++))
bart8785c122008-05-29 08:34:27 +000026 do
bartc4a174f2008-06-03 11:41:19 +000027 echo "$VG --tool=exp-drd $@ -p$p"
28 for ((i=0;i<3;i++))
29 do
30 /usr/bin/time --format="%e" $VG --tool=exp-drd "$@" -p$p 2>&1 | tail -n 1
31 done | avgstddev > "$tmp"
32 read avg2 stddev2 < "$tmp"
33 echo "Average time: ${avg2} +/- ${stddev2} seconds"
34 awk "END{print "'"'"Ratio ="'"'", ${avg2}/${avg1}, "'"'"+/-"'"'", ${avg2}/${avg1}*(${stddev1}/${avg1}+${stddev2}/${avg2})}" </dev/null
35 done
bart8785c122008-05-29 08:34:27 +000036
37 echo ''
38
39 rm -f "$tmp"
40}
41
42
43# Script body
44
bartc4a174f2008-06-03 11:41:19 +000045SPLASH2="$(dirname $0)/../splash2"
46if [ ! -e "${SPLASH2}" ]; then
47 echo "Error: splash2 directory not found (${SPLASH2})."
bart8785c122008-05-29 08:34:27 +000048 exit 1
49fi
50
51if [ "$VG" = "" ]; then
bartc4a174f2008-06-03 11:41:19 +000052 VG="$(dirname $0)/../../vg-in-place"
bart8785c122008-05-29 08:34:27 +000053fi
54
55if [ ! -e "$VG" ]; then
56 echo "Could not find $VG."
57 exit 1
58fi
59
bartc4a174f2008-06-03 11:41:19 +000060# Results: (-p1) (-p2) (-p3) (-p4) ITC (-p4)
61# lu, contiguous blocks: 40 48 53 55 420
62# lu, non-contiguous blocks: 37 47 55 58 420
63# radiosity: 99 99 99 99 490
bart8785c122008-05-29 08:34:27 +000064
bartf06b4272008-05-30 09:52:13 +000065# lu, contiguous blocks.
bartc4a174f2008-06-03 11:41:19 +000066run_test ${SPLASH2}/codes/kernels/lu/contiguous_blocks/LU -n1024
bart8785c122008-05-29 08:34:27 +000067
bartf06b4272008-05-30 09:52:13 +000068# lu, non-contiguous blocks.
bartc4a174f2008-06-03 11:41:19 +000069run_test ${SPLASH2}/codes/kernels/lu/non_contiguous_blocks/LU -n1024
bart8785c122008-05-29 08:34:27 +000070
bartf06b4272008-05-30 09:52:13 +000071# radiosity.
bartc4a174f2008-06-03 11:41:19 +000072run_test ${SPLASH2}/codes/apps/radiosity/RADIOSITY -batch -room
73
74
75# Local variables:
76# compile-command: "./run-splash2"
77# End: