-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_all_examples.sh
executable file
·297 lines (231 loc) · 9.09 KB
/
run_all_examples.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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/bash
# ---------------------------------------------------------------------------
# Intel Concurrent Collections for Haskell
# Copyright (c) 2010, Intel Corporation.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU Lesser General Public License,
# version 2.1, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
# ---------------------------------------------------------------------------
# This will put all the example programs through the paces under all
# possible scheduler configurations.
# ---------------------------------------------------------------------------
# Usage: [set env vars] ./run_all_tests
# Call it with environment variable LONGRUN=1 to get a longer run that
# can serve as benchmarks.
# Call it with THREADSETTINGS="1 2 4" to run with # threads = 1, 2, or 4.
# Call it with NONSTRICT=1 to keep going after the first error.
# Call it with TRIALS=N to control the number of times each benchmark is run.
# ---------------------------------------------------------------------------
# Settings:
# ----------------------------------------
#export GHC=ghc-6.13.20100511
#export GHC=~/bin/Linux-i686/bin/ghc-6.13.20100511
unset HASKELLCNC
export HASKELLCNC=`pwd`
# Which subset of schedures should we test:
PURESCHEDS="2 3"
#PURESCHEDS=""
IOSCHEDS="4 7 8 3 10 11"
#SEPARATESCHEDS="6"
SEPARATESCHEDS=""
if [ "$THREADSETTINGS" == "" ]
then THREADSETTINGS="4"
#then THREADSETTINGS="0 1 2 3 4"
fi
if [ "$GHC" == "" ]; then GHC=ghc; fi
source default_opt_settings.sh
# HACK: with all the intermachine syncing and different version control systems I run into permissions problems sometimes.
chmod +x ./ntime* ./*.sh
# Where to put the timing results:
RESULTS=results.dat
if [ -e $RESULTS ];
then BAK="$RESULTS".bak.`date +%s`
echo "Backing up old results to $BAK"
mv $RESULTS $BAK
fi
# How many times to run a process before taking the best time:
if [ "$TRIALS" == "" ]; then
TRIALS=1
fi
# Determine number of hardware threads on the machine:
# if [ -f /proc/cpuinfo ];
if [ -d /sys/devices/system/cpu/ ];
then
MAXTHREADS=`ls /sys/devices/system/cpu/ | grep "cpu[0123456789]*$" | wc -l`
echo "Detected the number of CPUs on the machine to be $MAXTHREADS"
elif [ `uname` == "Darwin" ];
then MAXTHREADS=`sysctl -n hw.ncpu`
else MAXTHREADS=2
fi
# ================================================================================
echo "# TestName Variant Scheduler NumThreads HashHackEnabled MinTime MedianTime MaxTime" > $RESULTS
echo "# "`date` >> $RESULTS
echo "# "`uname -a` >> $RESULTS
echo "# "`$GHC -V` >> $RESULTS
echo "# "
echo "# Running each test for $TRIALS trials." >> $RESULTS
echo "# ... with default compiler options: $GHC_DEFAULT_FLAGS" >> $RESULTS
echo "# ... with default runtime options: $GHC_DEFAULT_RTS" >> $RESULTS
cnt=0
source run_all_shared.sh
# Dynamic scoping. Lame. This uses $test.
function runit()
{
cnt=$((cnt+1))
echo
echo "--------------------------------------------------------------------------------"
echo " Running Config $cnt: $test variant $CNC_VARIANT sched $CNC_SCHEDULER threads $NUMTHREADS $hashtab"
echo "--------------------------------------------------------------------------------"
echo
echo "(In directory `pwd`)"
if [ "$NUMTHREADS" != "0" ] && [ "$NUMTHREADS" != "" ]
then export RTS=" $GHC_DEFAULT_RTS -s -N$NUMTHREADS "
else export RTS=""
fi
if [ "$hashtab" == "" ];
then HASH="0"
else HASH="1"
fi
# We compile the test case using runcnc:
NORUN=1 ./runcnc $hashtab examples/"$test".hs
CODE=$?
check_error $CODE "ERROR: compilation failed."
echo "Executing $NTIMES $TRIALS ./examples/$test.exe $ARGS +RTS $RTS -RTS "
if [ "$LONGRUN" == "" ]; then export HIDEOUTPUT=1; fi
# Hack, don't bother running the multiple trials under a threshold:
if [ "TRIALSTHRESHOLD" == "" ]
# TODO: IMPLEMENT THIS POLICY
then thistrials=$TRIALS
else thistrials=$TRIALS
fi
# Another option woud be dynamic feedback where if the first one
# takes a long time we don't bother doing more trials.
times=`$NTIMES "$thistrials" ./examples/$test.exe $ARGS +RTS $RTS -RTS`
CODE=$?
echo " >>> MIN/MEDIAN/MAX TIMES $times"
check_error $CODE "ERROR: run_all_tests this test failed completely: $test.exe"
if [ "$CODE" == "143" ];
then echo "$test.exe" "$CNC_VARIANT" "$CNC_SCHEDULER" "$NUMTHREADS" "$HASH" "TIMEOUT TIMEOUT TIMEOUT" >> $RESULTS
elif [ "$CODE" != "0" ] ;
then echo "$test.exe" "$CNC_VARIANT" "$CNC_SCHEDULER" "$NUMTHREADS" "$HASH" "ERR ERR ERR" >> $RESULTS
else
echo "$test.exe" "$CNC_VARIANT" "$CNC_SCHEDULER" "$NUMTHREADS" "$HASH" "$times" >> $RESULTS
fi
}
echo "Running all tests, for THREADSETTINGS in {$THREADSETTINGS}"
echo
# Build the timeout script if it hasn't been already:
if ! [ -e ./timeout ]; then
ghc --make timeout.hs -threaded
if [ "$?" != "0" ];
then echo "GHC build of timeout.hs returned error."
exit 1
fi
fi
# Hygiene:
rm -f examples/*.exe
#====================================================================================================
function run_benchmark() {
set -- $line
test=$1; shift
if [ "$LONGRUN" == "" ];
# If we're not in LONGRUN mode we run each executable with no
# arguments causing it to go to its default problem size.
then ARGS=
else ARGS=$*
fi
echo "================================================================================"
echo " Running Test: $test.exe $ARGS "
echo "================================================================================"
echo "# *** Config [$cnt ..], testing with command/args: $test.exe $ARGS " >> $RESULTS
export CNC_VARIANT=io
for sched in $IOSCHEDS; do
export CNC_SCHEDULER=$sched
#for NUMTHREADS in 4; do
# This one is serial right now:
if [ "$sched" == "100" ]; then
NUMTHREADS=1
export hashtab=""
runit
else
for NUMTHREADS in $THREADSETTINGS; do
# Running with the hashtable hack off:
export hashtab=""
runit
# This one is incorrect and nondeterministic:
# export hashtab="-DHASHTABLE_TEST"; runit
done # threads
fi
echo >> $RESULTS;
done # schedulers
export CNC_VARIANT=pure
# Currently running the pure scheduler only in single threaded mode:
export NUMTHREADS=0
for sched in $PURESCHEDS; do
export CNC_SCHEDULER=$sched
unset hashtab
if [ "$sched" == "2" ]; then
export NUMTHREADS=0
runit
else
for NUMTHREADS in $THREADSETTINGS; do
runit
done # threads
fi
echo >> $RESULTS;
done
# Finally, run once through separately compiled modules to compare performance (and make sure they build).
# This will basically use the IO based implementation with the default scheduler.
export CNC_VARIANT=separatemodule_io
for sched in $SEPARATESCHEDS; do
export CNC_SCHEDULER=$sched
export NUMTHREADS=4
runit
done
echo >> $RESULTS;
echo >> $RESULTS;
}
# Read $line and do the benchmark with ntimes_binsearch.sh
function run_binsearch_benchmark() {
NTIMES=./ntimes_binsearch.sh
run_benchmark
NTIMES=UNSET
}
# Read $line and do the benchmark with ntimes_minmedmax
function run_normal_benchmark() {
NTIMES=./ntimes_minmedmax
run_benchmark
NTIMES=UNSET
}
#====================================================================================================
# This specifies the list of tests and their arguments for a "long" run:
#for line in "mandel_opt 1 300 300 4000" "mandel_opt 2 300 300 4000" "mandel_opt 3 300 300 4000" "mandel 300 300 4000"; do
# Even wasp could handle this one, right:
#
#for line in "par_seq_par_seq 8.5" "embarrassingly_par 9.2" "primes2 200000" "mandel 300 300 4000" "mandel_opt 1 300 300 4000" "sched_tree 18" "fib 20000" "threadring 50000000 503" "nbody 1200" "primes 200000"; do
# Parallel benchmarks only:
#for line in "blackscholes 10000 15000000" "nbody 5000" "cholesky 1000 50 m1000.in" "par_seq_par_seq 8.5" "embarrassingly_par 9.2" "primes2 200000" "mandel 300 300 4000" "mandel_opt2 1 300 300 4000" "sched_tree 18" "primes 200000";
# FOR BIG machines, copied back from run_all_FROMPACKED
# for line in "nbody 10000" "blackscholes 10000 50000000" "mandel 150 150 160000" "mandel_opt2 2 150 150 160000" "cholesky 1000 50 cholesky_matrix1000.dat" "primes 1000000" "embarrassingly_par 9.8" "par_seq_par_seq 9.2" "sched_tree 19" ;
if [ "$BENCHLIST" == "" ];
then BENCHLIST="./benchlist.txt"
fi
echo Reading benchmarks from $BENCHLIST ...
cat $BENCHLIST | grep -v "\#" |
while read line
do
if [ "$line" == "" ]; then continue; fi
echo RUNNING BENCH: $line
run_normal_benchmark
done
echo "Finished with all test configurations."