blob: 2ab8a5d6f4ab040276057afb0a04af19c322c0a1 [file] [log] [blame]
bart8785c122008-05-29 08:34:27 +00001#!/bin/bash
2
3########################
4# Function definitions #
5########################
6
bart32811502008-06-03 15:12:59 +00007function log2 {
8 local i
9
10 for ((i=0;i<64;i++))
11 do
12 if [ $((2**i)) = $1 ]; then
13 echo $i
14 return 0
15 fi
16 done
17 echo ""
18 return 1
19}
20
21function get_cache_size {
22 local s
23 s=$(</sys/devices/system/cpu/cpu0/cache/index2/size)
24 if [ "${s%M}" != "$s" ]; then
25 echo $((${s%M}*1024*1024))
26 elif [ "${s%K}" != "$s" ]; then
27 echo $((${s%K}*1024))
28 else
29 echo $s
30 fi
31}
32
bart8785c122008-05-29 08:34:27 +000033# Read a stream of numbers from stdin (one per line), and print the average
34# and standard deviation.
35function avgstddev {
bartf06b4272008-05-30 09:52:13 +000036 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 +000037}
38
39function run_test {
40 local tmp avg1=1 stddev1=1 avg2=1 stddev2=1
41
42 tmp="/tmp/test-timing.$$"
43 echo "$@"
44 for ((i=0;i<3;i++))
45 do
bart868d73a2008-06-04 13:02:22 +000046 cat "${test_input:-/dev/null}" | \
47 /usr/bin/time --format="%e" "$@" 2>&1 | \
48 tail -n 1
bart8785c122008-05-29 08:34:27 +000049 done | avgstddev > "$tmp"
50 read avg1 stddev1 < "$tmp"
51 echo "Average time: ${avg1} +/- ${stddev1} seconds"
52
bart868d73a2008-06-04 13:02:22 +000053 for p in 1 2 4
bart8785c122008-05-29 08:34:27 +000054 do
bartc4a174f2008-06-03 11:41:19 +000055 echo "$VG --tool=exp-drd $@ -p$p"
56 for ((i=0;i<3;i++))
57 do
bart868d73a2008-06-04 13:02:22 +000058 cat "${test_input:-/dev/null}" | \
59 /usr/bin/time --format="%e" $VG --tool=exp-drd "$@" -p$p 2>&1 | \
60 tail -n 1
bartc4a174f2008-06-03 11:41:19 +000061 done | avgstddev > "$tmp"
62 read avg2 stddev2 < "$tmp"
63 echo "Average time: ${avg2} +/- ${stddev2} seconds"
64 awk "END{print "'"'"Ratio ="'"'", ${avg2}/${avg1}, "'"'"+/-"'"'", ${avg2}/${avg1}*(${stddev1}/${avg1}+${stddev2}/${avg2})}" </dev/null
65 done
bart8785c122008-05-29 08:34:27 +000066
67 echo ''
68
69 rm -f "$tmp"
70}
71
72
73# Script body
74
bart32811502008-06-03 15:12:59 +000075DRD_SCRIPTS_DIR="$(dirname $0)"
76if [ "${DRD_SCRIPTS_DIR}" = "." ]; then
77 DRD_SCRIPTS_DIR="$PWD"
78fi
79
80SPLASH2="${DRD_SCRIPTS_DIR}/../splash2"
bartc4a174f2008-06-03 11:41:19 +000081if [ ! -e "${SPLASH2}" ]; then
82 echo "Error: splash2 directory not found (${SPLASH2})."
bart8785c122008-05-29 08:34:27 +000083 exit 1
84fi
85
86if [ "$VG" = "" ]; then
bart32811502008-06-03 15:12:59 +000087 VG="${DRD_SCRIPTS_DIR}/../../vg-in-place"
bart8785c122008-05-29 08:34:27 +000088fi
89
90if [ ! -e "$VG" ]; then
91 echo "Could not find $VG."
92 exit 1
93fi
94
bart32811502008-06-03 15:12:59 +000095# Results: (-p1) (-p2) (-p3) (-p4) ITC (-p4) ITC (-p4)
96# original w/ filter
97# .........................................................................
98# Cholesky 46 59 75 92 239 82
bart868d73a2008-06-04 13:02:22 +000099# FFT 15 19 N/A 47 90 41
bart32811502008-06-03 15:12:59 +0000100# LU, contiguous blocks 40 48 53 55 428 128
101# LU, non-contiguous blocks 37 47 55 58 428 128
bart868d73a2008-06-04 13:02:22 +0000102# Ocean, contiguous partitions 20 26 N/A 32 90 28
103# Ocean, non-continguous partns 19 24 N/A 34 90 28
bart32811502008-06-03 15:12:59 +0000104# Radiosity 99 99 99 99 485 163
bart868d73a2008-06-04 13:02:22 +0000105# Radix 11 15 ? 17 222 56
106# Raytrace 75 75 ? 75 172 53
107# Water-n2 290 290 ? 290 189 39
108# Water-sp 288 288 ? 287 183 34
bart8785c122008-05-29 08:34:27 +0000109
bart32811502008-06-03 15:12:59 +0000110cache_size=$(get_cache_size)
111log2_cache_size=$(log2 ${cache_size})
112
113# Cholesky
bart32811502008-06-03 15:12:59 +0000114(
bart868d73a2008-06-04 13:02:22 +0000115 cd ${SPLASH2}/codes/kernels/cholesky/inputs
116 for f in *Z
117 do
118 gzip -cd <$f >${f%.Z}
119 done
120 run_test ../CHOLESKY -C${cache_size} -n1024 tk29.O
bart32811502008-06-03 15:12:59 +0000121)
bart32811502008-06-03 15:12:59 +0000122
123# FFT
bart868d73a2008-06-04 13:02:22 +0000124run_test ${SPLASH2}/codes/kernels/fft/FFT -t -l${log2_cache_size} -m20
bart32811502008-06-03 15:12:59 +0000125
126# LU, contiguous blocks.
bartc4a174f2008-06-03 11:41:19 +0000127run_test ${SPLASH2}/codes/kernels/lu/contiguous_blocks/LU -n1024
bart8785c122008-05-29 08:34:27 +0000128
bart32811502008-06-03 15:12:59 +0000129# LU, non-contiguous blocks.
bartc4a174f2008-06-03 11:41:19 +0000130run_test ${SPLASH2}/codes/kernels/lu/non_contiguous_blocks/LU -n1024
bart8785c122008-05-29 08:34:27 +0000131
bart868d73a2008-06-04 13:02:22 +0000132# Ocean
133run_test ${SPLASH2}/codes/apps/ocean/contiguous_partitions/OCEAN -n2050
134run_test ${SPLASH2}/codes/apps/ocean/non_contiguous_partitions/OCEAN -n258
135
bart32811502008-06-03 15:12:59 +0000136# Radiosity.
bartc4a174f2008-06-03 11:41:19 +0000137run_test ${SPLASH2}/codes/apps/radiosity/RADIOSITY -batch -room
138
bart868d73a2008-06-04 13:02:22 +0000139# Radix
140run_test ${SPLASH2}/codes/kernels/radix/RADIX -n$((2**24))
141
142# Raytrace
143(
144 cd ${SPLASH2}/codes/apps/raytrace/inputs
145 rm -f *.env *.geo *.rl
146 for f in *Z
147 do
148 gzip -cd <$f >${f%.Z}
149 done
150 run_test ../RAYTRACE balls4.env
151)
152run_test ${SPLASH2}/codes/apps/radiosity/RADIOSITY -batch -room
153
154# Water-n2
155rm -f water-n2-input
156echo "1.5e-16 32768 3 6 -1 3000 3 0 1 6.212752" > water-n2-input
157test_input=water-n2-input \
158 run_test ${SPLASH2}/codes/apps/water-nsquared/WATER-NSQUARED
159
160# Water-sp
161rm -f water-sp-input
162echo "1.5e-16 32768 3 6 -1 3000 3 0 1 6.212752" > water-sp-input
163test_input=water-sp-input \
164 run_test ${SPLASH2}/codes/apps/water-nsquared/WATER-NSQUARED
165
166
bartc4a174f2008-06-03 11:41:19 +0000167
168# Local variables:
169# compile-command: "./run-splash2"
170# End: