blob: 4243cd7dfbecb24b19c90fceb2edccdb5102a942 [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.$$"
bart334db5e2008-06-05 10:14:53 +000043 rm -f "${tmp}"
44
bart8785c122008-05-29 08:34:27 +000045 echo "$@"
46 for ((i=0;i<3;i++))
47 do
bart868d73a2008-06-04 13:02:22 +000048 cat "${test_input:-/dev/null}" | \
49 /usr/bin/time --format="%e" "$@" 2>&1 | \
50 tail -n 1
bart8785c122008-05-29 08:34:27 +000051 done | avgstddev > "$tmp"
52 read avg1 stddev1 < "$tmp"
53 echo "Average time: ${avg1} +/- ${stddev1} seconds"
54
bart868d73a2008-06-04 13:02:22 +000055 for p in 1 2 4
bart8785c122008-05-29 08:34:27 +000056 do
bartc4a174f2008-06-03 11:41:19 +000057 echo "$VG --tool=exp-drd $@ -p$p"
58 for ((i=0;i<3;i++))
59 do
bart868d73a2008-06-04 13:02:22 +000060 cat "${test_input:-/dev/null}" | \
61 /usr/bin/time --format="%e" $VG --tool=exp-drd "$@" -p$p 2>&1 | \
62 tail -n 1
bartc4a174f2008-06-03 11:41:19 +000063 done | avgstddev > "$tmp"
64 read avg2 stddev2 < "$tmp"
65 echo "Average time: ${avg2} +/- ${stddev2} seconds"
66 awk "END{print "'"'"Ratio ="'"'", ${avg2}/${avg1}, "'"'"+/-"'"'", ${avg2}/${avg1}*(${stddev1}/${avg1}+${stddev2}/${avg2})}" </dev/null
67 done
bart8785c122008-05-29 08:34:27 +000068
69 echo ''
70
71 rm -f "$tmp"
72}
73
74
75# Script body
76
bart32811502008-06-03 15:12:59 +000077DRD_SCRIPTS_DIR="$(dirname $0)"
78if [ "${DRD_SCRIPTS_DIR}" = "." ]; then
79 DRD_SCRIPTS_DIR="$PWD"
80fi
81
82SPLASH2="${DRD_SCRIPTS_DIR}/../splash2"
bartc4a174f2008-06-03 11:41:19 +000083if [ ! -e "${SPLASH2}" ]; then
84 echo "Error: splash2 directory not found (${SPLASH2})."
bart8785c122008-05-29 08:34:27 +000085 exit 1
86fi
87
88if [ "$VG" = "" ]; then
bart32811502008-06-03 15:12:59 +000089 VG="${DRD_SCRIPTS_DIR}/../../vg-in-place"
bart8785c122008-05-29 08:34:27 +000090fi
91
92if [ ! -e "$VG" ]; then
93 echo "Could not find $VG."
94 exit 1
95fi
96
bart32811502008-06-03 15:12:59 +000097# Results: (-p1) (-p2) (-p3) (-p4) ITC (-p4) ITC (-p4)
98# original w/ filter
99# .........................................................................
100# Cholesky 46 59 75 92 239 82
bart868d73a2008-06-04 13:02:22 +0000101# FFT 15 19 N/A 47 90 41
bart32811502008-06-03 15:12:59 +0000102# LU, contiguous blocks 40 48 53 55 428 128
103# LU, non-contiguous blocks 37 47 55 58 428 128
bart868d73a2008-06-04 13:02:22 +0000104# Ocean, contiguous partitions 20 26 N/A 32 90 28
105# Ocean, non-continguous partns 19 24 N/A 34 90 28
bart32811502008-06-03 15:12:59 +0000106# Radiosity 99 99 99 99 485 163
bart868d73a2008-06-04 13:02:22 +0000107# Radix 11 15 ? 17 222 56
108# Raytrace 75 75 ? 75 172 53
bart334db5e2008-06-05 10:14:53 +0000109# Water-n2 50 50 ? 50 189 39
110# Water-sp 49 48 ? 49 183 34
bart8785c122008-05-29 08:34:27 +0000111
bart32811502008-06-03 15:12:59 +0000112cache_size=$(get_cache_size)
113log2_cache_size=$(log2 ${cache_size})
114
115# Cholesky
bart32811502008-06-03 15:12:59 +0000116(
bart868d73a2008-06-04 13:02:22 +0000117 cd ${SPLASH2}/codes/kernels/cholesky/inputs
118 for f in *Z
119 do
120 gzip -cd <$f >${f%.Z}
121 done
122 run_test ../CHOLESKY -C${cache_size} -n1024 tk29.O
bart32811502008-06-03 15:12:59 +0000123)
bart32811502008-06-03 15:12:59 +0000124
125# FFT
bart868d73a2008-06-04 13:02:22 +0000126run_test ${SPLASH2}/codes/kernels/fft/FFT -t -l${log2_cache_size} -m20
bart32811502008-06-03 15:12:59 +0000127
128# LU, contiguous blocks.
bartc4a174f2008-06-03 11:41:19 +0000129run_test ${SPLASH2}/codes/kernels/lu/contiguous_blocks/LU -n1024
bart8785c122008-05-29 08:34:27 +0000130
bart32811502008-06-03 15:12:59 +0000131# LU, non-contiguous blocks.
bartc4a174f2008-06-03 11:41:19 +0000132run_test ${SPLASH2}/codes/kernels/lu/non_contiguous_blocks/LU -n1024
bart8785c122008-05-29 08:34:27 +0000133
bart868d73a2008-06-04 13:02:22 +0000134# Ocean
135run_test ${SPLASH2}/codes/apps/ocean/contiguous_partitions/OCEAN -n2050
136run_test ${SPLASH2}/codes/apps/ocean/non_contiguous_partitions/OCEAN -n258
137
bart32811502008-06-03 15:12:59 +0000138# Radiosity.
bartc4a174f2008-06-03 11:41:19 +0000139run_test ${SPLASH2}/codes/apps/radiosity/RADIOSITY -batch -room
140
bart868d73a2008-06-04 13:02:22 +0000141# Radix
142run_test ${SPLASH2}/codes/kernels/radix/RADIX -n$((2**24))
143
144# Raytrace
145(
146 cd ${SPLASH2}/codes/apps/raytrace/inputs
147 rm -f *.env *.geo *.rl
148 for f in *Z
149 do
150 gzip -cd <$f >${f%.Z}
151 done
152 run_test ../RAYTRACE balls4.env
153)
bart334db5e2008-06-05 10:14:53 +0000154
155# Radiosity
bart868d73a2008-06-04 13:02:22 +0000156run_test ${SPLASH2}/codes/apps/radiosity/RADIOSITY -batch -room
157
158# Water-n2
bart334db5e2008-06-05 10:14:53 +0000159(
160 cd ${SPLASH2}/codes/apps/water-nsquared
161 test_input=input run_test ./WATER-NSQUARED
162)
bart868d73a2008-06-04 13:02:22 +0000163
164# Water-sp
bart334db5e2008-06-05 10:14:53 +0000165(
166 cd ${SPLASH2}/codes/apps/water-spatial
167 test_input=input run_test ./WATER-SPATIAL
168)
bart868d73a2008-06-04 13:02:22 +0000169
170
bartc4a174f2008-06-03 11:41:19 +0000171
172# Local variables:
173# compile-command: "./run-splash2"
174# End: