/
Makefile
307 lines (236 loc) · 12 KB
/
Makefile
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
298
299
300
301
302
303
304
305
306
307
FUTHARK_OPENCL?=futhark-opencl
RODINIA_URL=http://www.cs.virginia.edu/~kw5na/lava/Rodinia/Packages/Current/rodinia_3.1.tar.bz2
RODINIA_MD5=047d983e62107972f217921aa0027b05 rodinia_3.1.tar.bz2
# Parboil insists on some click-through license, so you'll have to get
# it on your own.
PARBOIL_LOCATION?=$(HOME)/parboil
RUNS=10
RODINIA_BENCHMARKS=srad hotspot nn backprop cfd kmeans lavaMD pathfinder myocyte
ACCELERATE_BENCHMARKS=fluid mandelbrot nbody crystal
FINPAR_BENCHMARKS=LocVolCalib_large OptionPricing_large
PARBOIL_BENCHMARKS=mri-q
OPENCL_BENCHMARKS=srad hotspot nn backprop cfd kmeans lavaMD pathfinder mri-q LocVolCalib_large OptionPricing_large
EASIEST_BENCHMARKS=srad hotspot nn backprop cfd kmeans lavaMD pathfinder LocVolCalib_large OptionPricing_large
.PHONY: clean speedup.pdf runtimes.tex
.SECONDARY:
all: benchmark
benchmark: benchmark_rodinia benchmark_accelerate benchmark_finpar benchmark_parboil
benchmark_futhark: $(RODINIA_BENCHMARKS:%=runtimes/%-futhark.avgtime) $(ACCELERATE_BENCHMARKS:%=runtimes/%-futhark.avgtime) $(FINPAR_BENCHMARKS:%=runtimes/%-futhark.avgtime) $(PARBOIL_BENCHMARKS:%=runtimes/%-futhark.avgtime)
benchmark_easiest: $(OPENCL_BENCHMARKS:%=runtimes/%.speedup)
benchmark_opencl: $(OPENCL_BENCHMARKS:%=runtimes/%.speedup)
benchmark_rodinia: $(RODINIA_BENCHMARKS:%=runtimes/%.speedup)
benchmark_accelerate: $(ACCELERATE_BENCHMARKS:%=runtimes/%.speedup)
benchmark_finpar: $(FINPAR_BENCHMARKS:%=runtimes/%.speedup)
benchmark_parboil: $(PARBOIL_BENCHMARKS:%=runtimes/%.speedup)
speedup.pdf:
python tools/plot.py $@
runtimes.tex:
python tools/table.py > $@ || rm -f $@
runtimes/%.speedup: runtimes/%-futhark.avgtime runtimes/%-rodinia.avgtime
@echo "scale=2; $(shell cat runtimes/$*-rodinia.avgtime) / $(shell cat runtimes/$*-futhark.avgtime)" | bc > $@
runtimes/%.speedup: runtimes/%-futhark.avgtime runtimes/%-accelerate.avgtime
@echo "scale=2; $(shell cat runtimes/$*-accelerate.avgtime) / $(shell cat runtimes/$*-futhark.avgtime)" | bc > $@
runtimes/%.speedup: runtimes/%-futhark.avgtime runtimes/%-finpar.avgtime
@echo "scale=2; $(shell cat runtimes/$*-finpar.avgtime) / $(shell cat runtimes/$*-futhark.avgtime)" | bc > $@
runtimes/%.speedup: runtimes/%-futhark.avgtime runtimes/%-parboil.avgtime
@echo "scale=2; $(shell cat runtimes/$*-parboil.avgtime) / $(shell cat runtimes/$*-futhark.avgtime)" | bc > $@
runtimes/%.avgtime: runtimes/%.runtimes
@awk '{sum += strtonum($$0) / 1000.0} END{print sum/NR}' < $< > $@
runtimes/%-accelerate.avgtime: runtimes/%-accelerate.csv
@tail -n 1 $< | cut -d',' -f2 | awk '{print $$1*1000}' > $@
runtimes/srad-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/srad && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/srad/runtimes $@
runtimes/srad-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/srad/srad.fut
$</rodinia/srad/srad -r $(RUNS) -t $@ < $</rodinia/srad/data/image.in > /dev/null
runtimes/hotspot-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/hotspot && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/hotspot/runtimes $@
runtimes/hotspot-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/hotspot/hotspot.fut
$</rodinia/hotspot/hotspot -r $(RUNS) -t $@ < $</rodinia/hotspot/data/1024.in > /dev/null
runtimes/nn-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/nn && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/nn/runtimes $@
runtimes/nn-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/nn/nn.fut
$</rodinia/nn/nn -r $(RUNS) -t $@ < $</rodinia/nn/data/medium.in > /dev/null
runtimes/backprop-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/backprop && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/backprop/runtimes $@
runtimes/backprop-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/backprop/backprop.fut
$</rodinia/backprop/backprop -r $(RUNS) -t $@ < $</rodinia/backprop/data/medium.in > /dev/null
runtimes/cfd-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/cfd && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/cfd/runtimes $@
runtimes/cfd-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/cfd/cfd.fut
$</rodinia/cfd/cfd -r $(RUNS) -t $@ < $</rodinia/cfd/data/fvcorr.domn.193K.toa > /dev/null
runtimes/kmeans-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/kmeans && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/kmeans/runtimes $@
runtimes/kmeans-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/kmeans/kmeans.fut
$</rodinia/kmeans/kmeans -r $(RUNS) -t $@ < $</rodinia/kmeans/data/kdd_cup.in > /dev/null
runtimes/lavaMD-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/lavaMD && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/lavaMD/runtimes $@
runtimes/lavaMD-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/lavaMD/lavaMD.fut
$</rodinia/lavaMD/lavaMD -r $(RUNS) -t $@ < $</rodinia/lavaMD/data/10_boxes.in > /dev/null
runtimes/pathfinder-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</opencl/pathfinder && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</opencl/pathfinder/runtimes $@
runtimes/pathfinder-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/pathfinder/pathfinder.fut
$</rodinia/pathfinder/pathfinder -r $(RUNS) -t $@ < $</rodinia/pathfinder/data/medium.in > /dev/null
# Myocyte uses the CUDA version, because the OpenCL one does not
# support the workload>1 case efficiently.
runtimes/myocyte-rodinia.runtimes: rodinia_3.1-patched
@mkdir -p runtimes
(cd $</cuda/myocyte && make clean && make && RODINIA_RUNS=$(RUNS) ./run)
cp $</cuda/myocyte/runtimes $@
runtimes/myocyte-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) $</rodinia/myocyte/myocyte.fut
$</rodinia/myocyte/myocyte -r $(RUNS) -t $@ < $</rodinia/myocyte/data/medium.in > /dev/null
# Accelerate uses its own internal benchmarking and computes its own
# averages. Hack: Some of these benchmarks terminate incorrectly with
# 'Not a valid Unicode code point!', so we ignore their exit code.
# The following constants define the work size for fluid.
FLUID_N_STEPS=1
FLUID_RESOLUTION=3000 # ends up squared
FLUID_N_SOLVER_STEPS=20
runtimes/fluid-accelerate.csv:
@mkdir -p runtimes
accelerate-fluid --cuda --benchmark --csv=$@ \
--iterations=$(FLUID_N_SOLVER_STEPS) \
--width=$(FLUID_RESOLUTION) \
--height=$(FLUID_RESOLUTION) || true
input/fluid.input:
@mkdir -p input
futhark-benchmarks/accelerate/fluid/fluid-generate-random-input.py \
$(FLUID_N_STEPS) $(FLUID_RESOLUTION) $(FLUID_N_SOLVER_STEPS) futhark none > $@
runtimes/fluid-futhark.runtimes: futhark-benchmarks input/fluid.input
@mkdir -p runtimes
$(FUTHARK_OPENCL) futhark-benchmarks/accelerate/fluid/src-futhark/fluid-benchmark.fut
futhark-benchmarks/accelerate/fluid/src-futhark/fluid-benchmark -r $(RUNS) -t $@ < input/fluid.input > /dev/null
MANDELBROT_RESOLUTION=4000
MANDELBROT_LIMIT=255
runtimes/mandelbrot-accelerate.csv:
@mkdir -p runtimes
accelerate-mandelbrot --cuda --benchmark --csv=$@ \
--width $(MANDELBROT_RESOLUTION) --height $(MANDELBROT_RESOLUTION) --limit $(MANDELBROT_LIMIT) || true
runtimes/mandelbrot-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) futhark-benchmarks/accelerate/mandelbrot/mandelbrot.fut
echo $(MANDELBROT_RESOLUTION) $(MANDELBROT_RESOLUTION) $(MANDELBROT_LIMIT) -2.23 -1.15 0.83 1.15 | \
futhark-benchmarks/accelerate/mandelbrot/mandelbrot -r $(RUNS) -t $@ > /dev/null
NBODY_N=100000
runtimes/nbody-accelerate.csv:
@mkdir -p runtimes
accelerate-nbody --cuda --benchmark -n $(NBODY_N) --csv=$@ || true
runtimes/nbody-futhark.runtimes: futhark-benchmarks
@mkdir -p runtimes
$(FUTHARK_OPENCL) futhark-benchmarks/accelerate/nbody/nbody.fut
cat futhark-benchmarks/accelerate/nbody/nbody-n_steps=1-n_bodies=$(NBODY_N)-timestep=1.0-epsilon=50.0.in | \
futhark-benchmarks/accelerate/nbody/nbody -r $(RUNS) -t $@ > /dev/null
CRYSTAL_SIZE=2000
CRYSTAL_DEGREE=50
runtimes/crystal-accelerate.csv:
@mkdir -p runtimes
accelerate-crystal --cuda --benchmark --size $(CRYSTAL_SIZE) --degree $(CRYSTAL_DEGREE) --csv=$@ || true
runtimes/crystal-futhark.runtimes: futhark-benchmarks
$(FUTHARK_OPENCL) futhark-benchmarks/accelerate/crystal/crystal.fut
echo $(CRYSTAL_SIZE) 30.0 $(CRYSTAL_DEGREE) 1 1.0 | \
futhark-benchmarks/accelerate/crystal/crystal -r $(RUNS) -t $@ > /dev/null
runtimes/LocVolCalib_%-finpar.runtimes: finpar
@mkdir -p runtimes
(cd finpar/LocVolCalib/OutParOpenCLMP; \
make; \
for i in `seq $(RUNS)`; do make run_$* | grep Runtime | cut -f1; done > ../../../$@)
futhark-benchmarks/finpar/LocVolCalib: futhark-benchmarks
$(FUTHARK_OPENCL) futhark-benchmarks/finpar/LocVolCalib.fut
runtimes/LocVolCalib_%-futhark.runtimes: futhark-benchmarks/finpar/LocVolCalib
@mkdir -p runtimes
cat futhark-benchmarks/finpar/LocVolCalib-data/$*.in | \
futhark-benchmarks/finpar/LocVolCalib -r $(RUNS) -t $@ > /dev/null
runtimes/OptionPricing_%-finpar.runtimes: finpar
@mkdir -p runtimes
(cd finpar/OptionPricing/CppOpenCL; \
make; \
for i in `seq $(RUNS)`; do make run_$* | grep Runtime | cut -f1; done > ../../../$@)
futhark-benchmarks/finpar/OptionPricing: futhark-benchmarks
$(FUTHARK_OPENCL) futhark-benchmarks/finpar/OptionPricing.fut
runtimes/OptionPricing_%-futhark.runtimes: futhark-benchmarks/finpar/OptionPricing
@mkdir -p runtimes
cat futhark-benchmarks/finpar/OptionPricing-data/$*.in | \
futhark-benchmarks/finpar/OptionPricing -r $(RUNS) -t $@ > /dev/null
runtimes/mri-q-parboil.runtimes:
@mkdir -p runtimes
(cd $(PARBOIL_LOCATION); \
for i in `seq $(RUNS)`; do \
./parboil run mri-q opencl large | awk '/^Kernel/{print int($$3*1000000)}'; \
done) > $@
runtimes/mri-q-futhark.runtimes:
@mkdir -p runtimes
$(FUTHARK_OPENCL) futhark-benchmarks/parboil/mri-q/mri-q.fut
cat futhark-benchmarks/parboil/mri-q/data/large.in | futhark-benchmarks/parboil/mri-q/mri-q -r $(RUNS) -t $@ > /dev/null
runtimes/sgemm-parboil.runtimes:
@mkdir -p runtimes
(cd $(PARBOIL_LOCATION); \
for i in `seq $(RUNS)`; do \
./parboil run sgemm cuda medium | awk '/^Kernel/{print int($$3*1000000)}'; \
done) > $@
futhark-benchmarks:
git clone --depth 1 https://github.com/HIPERFIT/futhark-benchmarks.git
finpar:
git clone https://github.com/HIPERFIT/finpar.git
rodinia_3.1-patched: rodinia_3.1.tar.bz2
@if ! md5sum --quiet -c rodinia_3.1.tar.bz2.md5; then \
echo "Your rodinia_3.1.tar.bz2 has the wrong MD5-sum - delete it and try again."; exit 1; fi
tar jxf rodinia_3.1.tar.bz2
mv rodinia_3.1 rodinia_3.1-patched
patch -p0 < rodinia_3.1-some-instrumentation.patch
rodinia_3.1.tar.bz2:
wget http://www.cs.virginia.edu/~kw5na/lava/Rodinia/Packages/Current/rodinia_3.1.tar.bz2
sanity_check_opencl:
gcc sanity/opencl.c -std=c99 -lOpenCL -o sanity/opencl
sanity/opencl
@echo Sanity-checking succeeded. You will probably be able to compile and run the OpenCL benchmarks.
sanity_check_cuda:
nvcc sanity/cuda.cu -o sanity/cuda
sanity/cuda
@echo Sanity-checking succeeded. You will probably be able to compile and run the CUDA benchmarks.
sanity_check_parboil:
cd $(PARBOIL_LOCATION) && ./parboil run sgemm opencl_base small
@echo Parboil sanity-checking succeeded. You will probably be able to compile and run the Parboil benchmarks.
benchmark_noinplace_kmeans: futhark-benchmarks
cp no_inplace/kmeans-no-inplace.fut futhark-benchmarks/rodinia/kmeans
futhark-bench --compiler=$(FUTHARK_OPENCL) futhark-benchmarks/rodinia/kmeans/kmeans-no-inplace.fut
benchmark_noinplace_LocVolCalib: futhark-benchmarks
cp no_inplace/LocVolCalib-no-inplace.fut futhark-benchmarks/finpar/
futhark-bench --compiler=$(FUTHARK_OPENCL) futhark-benchmarks/finpar/LocVolCalib-no-inplace.fut
clean:
rm -rf rodinia_3.1
cd futhark-benchmarks && git clean -f
rm -rf runtimes
rm -rf input