-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdobench.sh
More file actions
executable file
·249 lines (197 loc) · 6.58 KB
/
dobench.sh
File metadata and controls
executable file
·249 lines (197 loc) · 6.58 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/bin/sh
# see readme.txt for copyright info
# CONFIGURATION:
# command for RenderMan shader compiler
SHADER='shaderdl'
# command for RenderMan renderer
RENDER='renderdl'
# note: you are responsible for setting $PATH and $RMANTREE
# appropriately so that 'prman' will work.
# any extra flags you want to pass to prman
RENDERFLAGS='-progress'
# file for output of benchmark run
OUTPUT='output.txt'
#####################
# Gracefully exit on Ctrl-C and remove all temporary files
trap 'echo "Aborted." ; rm -f TEMP TIME SYSTEM_PROFILE; exit 1' TERM INT
# start time (for reporting use only, not for timing)
DATE=`date`
# determine operating system and # of CPUs
PLATFORM=`uname`
if [ "$PLATFORM" = "Linux" ]; then
echo "Detected OS: Linux"
CPUS=`grep processor /proc/cpuinfo | wc -l | sed 's/^[ \t]*//'`
elif [ "$PLATFORM" = "Darwin" ]; then
echo "Detected OS: Mac OSX"
CPUS=`sysctl -n machdep.cpu.core_count`
else
echo "This script is not compatible with this OS: $PLATFORM"
echo "Compile bench.sl and manually render each RIB file (except geom.rib)."
echo "For timing, uncomment the \"Option\" line at the top of each RIB."
exit 1
fi
if [ $CPUS -eq 1 ]; then
echo "Detected 1 CPU"
elif [ $CPUS -gt 1 ]; then
echo "Detected $CPUS CPUs"
fi
# test for presence of /usr/bin/time
if [ ! -x /usr/bin/time ]; then
echo "/usr/bin/time is not available - please install it."
echo "(on RedHat, install the 'time' RPM, on SuSE, install 'util-linux')"
echo "(on Debian, install the 'time' package)"
exit 1
fi
# compile the shader
echo "Compiling shaders ..."
if ! "$SHADER" bench.sl; then
echo "Error compiling shader bench.sl"
exit 1
fi
if ! "$SHADER" stucco.sl; then
echo "Error compiling shader stucco.sl"
exit 1
fi
# usage:
# timerender "shader" foo.rib 2
# arg1: user-visible name of this test
# arg2: RIB file to render
# arg3: # of processors to use
# puts elapsed wall-clock time in seconds in a file called TIME
function timerender {
echo "Running $1 benchmark "
if [ $3 -eq 1 ]; then
echo "(one thread)..."
elif [ $3 -gt 1 ]; then
echo "(multithreading)..."
else
echo "# of threads must be 1 or more (was $3)"
exit 1
fi
# run renderer
if [ "$PLATFORM" = "Linux" ]; then
/usr/bin/time -f %e -o TIME "$RENDER" $RENDERFLAGS -p:$3 $2
elif [ "$PLATFORM" = "Darwin" ]; then
# Mac OSX's time(1) command has no ability to output to a file
# so, redirect stderr to TEMP, then strip off everything but
# the wall clock time in seconds. We must run the renderer
# in a subshell in order to send its stderr to the console rather
# than the TEMP file.
/usr/bin/time sh -c "'$RENDER' $RENDERFLAGS -p:$3 $2 2>&1 " 2>TEMP && \
(sed 's/ real.*//' | sed 's/^[ \t]*//') < TEMP > TIME && rm TEMP
fi
# check return value from the render
if [ ! $? ]; then
echo "Error running $1 benchmark"
exit 1
fi
local RESULT=`cat TIME`
echo "$1 benchmark done: $RESULT sec"
}
echo "Running single thread benchmarks..."
timerender "shader" shader.rib 1
SHADERTIME=`cat TIME`
timerender "shader_vm" shader_vm.rib 1
SHADERVMTIME=`cat TIME`
timerender "hider" hider.rib 1
HIDERTIME=`cat TIME`
timerender "diffuse raytrace" raydiff.rib 1
RAYDIFFTIME=`cat TIME`
timerender "diffuse raytrace with displacements" raydiff_displacements.rib 1
RAYDIFFDISPTIME=`cat TIME`
timerender "diffuse raytrace with displacements" raydiff_shade.rib 1
RAYDIFFSHADETIME=`cat TIME`
timerender "specular raytrace" rayspec.rib 1
RAYSPECTIME=`cat TIME`
if [ $CPUS -gt 1 ]; then
echo "Running multithread benchmarks..."
timerender "shader" shader.rib $CPUS
DUALSHADERTIME=`cat TIME`
timerender "shader_vm" shader_vm.rib $CPUS
DUALSHADERVMTIME=`cat TIME`
timerender "hider" hider.rib $CPUS
DUALHIDERTIME=`cat TIME`
timerender "diffuse raytrace" raydiff.rib $CPUS
DUALRAYDIFFTIME=`cat TIME`
timerender "diffuse raytrace with displacements" raydiff_shade.rib $CPUS
DUALRAYDIFFSHADETIME=`cat TIME`
timerender "diffuse raytrace with displacements" raydiff_displacements.rib $CPUS
DUALRAYDIFFDISPTIME=`cat TIME`
timerender "specular raytrace with displacements" rayspec.rib $CPUS
DUALRAYSPECTIME=`cat TIME`
fi
echo "All benchmarks done."
# print output
cat > "$OUTPUT" <<EOF
RenderMan Benchmark v3
by Maas Digital LLC
(11 November 2004)
Run on $HOSTNAME at $DATE
Render command was $RENDER $RENDERFLAGS
EOF
# print renderer version
$RENDER -version >> "$OUTPUT" 2>&1
echo >> "$OUTPUT" # add a newline
# determine system info
if [ "$PLATFORM" = "Linux" ]; then
# Linux
echo "Gathering system info..."
OS=`uname -s -r`
NCPUS=`grep '^processor' /proc/cpuinfo | wc -l | sed 's/^[ \t]*//'`
CPUTYPE=`grep model\ name /proc/cpuinfo | head -n 1 | sed 's/.*: //'`
CPUSPD=`grep cpu\ MHz /proc/cpuinfo | head -n 1 | sed 's/.*: //'`
CPUCACHE=`grep cache\ size /proc/cpuinfo | head -n 1 | sed 's/.*: //'`
cat >> "$OUTPUT" <<EOF
System Info
-----------
OS: $OS
# of CPUs: $NCPUS (including HyperThreading virtual CPUs)
CPU type: $CPUTYPE
CPU speed: $CPUSPD MHz
CPU cache: $CPUCACHE
EOF
elif [ "$PLATFORM" = "Darwin" ]; then
# Mac OSX (use the file generated above with system_profiler)
cat SYSTEM_PROFILE | head -n 12 >> "$OUTPUT"
fi
cat >> "$OUTPUT" <<EOF
Single thread Benchmarks
------------------------
Shader time: $SHADERTIME sec
Shader VM time: $SHADERVMTIME sec
Hider time: $HIDERTIME sec
Diffuse raytrace time: $RAYDIFFTIME sec
Diffuse raytrace+disp time: $RAYDIFFDISPTIME sec
Diffuse raytrace+shade time: $RAYDIFFSHADETIME sec
Specular raytrace time: $RAYSPECTIME sec
EOF
if [ $CPUS -gt 1 ]; then
cat >> "$OUTPUT" <<EOF
Multithread Benchmarks
----------------------
Shader time: $DUALSHADERTIME sec
Shader VM time: $DUALSHADERVMTIME sec
Hider time: $DUALHIDERTIME sec
Diffuse raytrace time: $DUALRAYDIFFTIME sec
Diffuse raytrace+disp time: $DUALRAYDIFFDISPTIME sec
Diffuse raytrace+shade time: $DUALRAYDIFFSHADETIME sec
Specular raytrace time: $DUALRAYSPECTIME sec
EOF
fi
# append checksums of various files, to make sure
# they were not modified
echo "Checksums:" >> "$OUTPUT"
function do_md5sum {
if [ "$PLATFORM" = "Linux" ]; then
# Linux
md5sum "$@"
elif [ "$PLATFORM" = "Darwin" ]; then
# Mac OSX (munge md5 output to look like md5sum)
md5 "$@" | sed 's#MD5 (\(.*\)) = \(.*\)#\2 \1#'
fi
}
do_md5sum bench.sl shader.rib raydiff.rib rayspec.rib hider.rib geom.rib >> $OUTPUT
do_md5sum $OUTPUT >> $OUTPUT
# clean up
rm -f TEMP TIME SYSTEM_PROFILE
echo "Done. See results in $OUTPUT."