-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
executable file
·394 lines (276 loc) · 12.1 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
GCC = gcc
# add the directory of the nvcc compiler
NVCC = /usr/local/cuda-9.0/bin/nvcc
# add the directories of gsl library and cuda
GSL = /usr/local
CUDA = /usr/local/cuda-9.0
GCCFLAGS = -O3 -g
GCCFLAGS += -Wall
GCCFLAGS += -Wno-unused-function
NVCCFLAGS = -O3
NVCCFLAGS += --compiler-options -Wall
NVCCFLAGS += --compiler-options -Wno-unused-function
NVCCFLAGS += -rdc=true
GENCODE_FLAGS += -gencode arch=compute_61,code=compute_61
GCCLIBS += -L$(GSL)/lib
GCCLIBS += -lm -lgsl -lgslcblas
NVCCLIBS += -L$(CUDA)/lib64
NVCCLIBS += -lcudart -lcuda -lcudadevrt
NVCCLIBS += -lcublas -lcublas_device -lcurand
LIBRARIES = $(GCCLIBS) $(NVCCLIBS)
ifeq ($(OS),Windows_NT)
LDLIBS += -lws2_32
else
LDLIBS += -lrt
endif
SRC = src
OBJ = obj
BIN = bin
LIB = lib
OUT = out
SCR = scr
DATA = data
TESTS = tests
RES = res
CSVPARSER = $(LIB)/ccsvparser/src
UTIL = $(SRC)/util
MCMC_CPU = $(SRC)/mcmc_cpu
MCMC_GPU = $(SRC)/mcmc_gpu
MCMC_SP = $(SRC)/mcmc_gpu_sp
MCMC_MP = $(SRC)/mcmc_mp
RED = $(SRC)/reduction
DATA_SCRIPTS = $(SCR)/data_scr
PLOT_SCRIPTS = $(SCR)/plot_scr
SH_SCRIPTS = $(SCR)/sh_scr
VPATH = $(CSVPARSER) $(UTIL) $(RED)\
$(MCMC_CPU) $(MCMC_GPU) $(MCMC_MP) $(MCMC_SP)\
$(TESTS) $(DATA)\
$(DATA_SCRIPTS) $(PLOT_SCRIPTS) $(SH_SCRIPTS)
INCLUDES += -I$(GSL)/include -I$(CUDA)/include -Iinclude\
-I$(MCMC_CPU) -I$(MCMC_GPU) -I$(MCMC_MP) -I$(MCMC_SP)\
-I$(CSVPARSER) -I$(UTIL) -I$(RED)\
-I$(TESTS)
LIB_OBJ = $(OBJ)/csvparser.o
UTIL_OBJ = $(OBJ)/alloc_util.o $(OBJ)/data_util.o $(OBJ)/processing_util.o \
$(OBJ)/io.o
RED_OBJ = $(OBJ)/reduction_kernel.o
ALL_OBJ = $(LIB_OBJ) $(UTIL_OBJ) $(RED_OBJ)
CPU_OBJ = $(OBJ)/cpu_host.o $(OBJ)/mcmc_cpu.o
GPU_OBJ = $(OBJ)/mcmc_gpu.o $(OBJ)/gpu_host.o
SP_OBJ = $(OBJ)/mcmc_gpu_sp.o $(OBJ)/gpu_sp_host.o
MP_OBJ = $(OBJ)/mcmc_mp.o $(OBJ)/mp_host.o
RUNS_CPU_OBJ = $(OBJ)/mcmc_cpu.o $(OBJ)/multiple_runs_cpu.o
RUNS_GPU_OBJ = $(OBJ)/mcmc_gpu.o $(OBJ)/multiple_runs_gpu.o
RUNS_SP_OBJ = $(OBJ)/mcmc_gpu_sp.o $(OBJ)/multiple_runs_sp.o
TUNE_CPU_OBJ = $(OBJ)/mcmc_cpu.o $(OBJ)/tunning_cpu.o
LARGE_DATA_CPU_OBJ = $(OBJ)/mcmc_cpu.o $(OBJ)/large_data_cpu.o
GPU_PERFORMANCE_OBJ = $(OBJ)/mcmc_gpu.o $(OBJ)/gpu_perf.o
GPU_CPU_COMP_OBJ = $(OBJ)/mcmc_gpu.o $(OBJ)/mcmc_cpu.o $(OBJ)/compare_cpu_gpu.o
GPU_SP_COMP_OBJ = $(OBJ)/mcmc_gpu.o $(OBJ)/mcmc_gpu_sp.o $(OBJ)/compare_gpu_sp.o
TUNERS_CPU_OBJ = $(OBJ)/mcmc_gpu.o $(OBJ)/compare_tuners.o
all: clean samplers tests generateMnist
# samplers: $(BIN)/mcmc_cpu $(BIN)/mcmc_gpu $(BIN)/mcmc_sp $(BIN)/mcmc_mp
samplers: $(BIN)/mcmc_cpu $(BIN)/mcmc_gpu $(BIN)/mcmc_sp
tests: mulRuns tuneCpu perf comp
mulRuns: $(BIN)/mul_runs_cpu $(BIN)/mul_runs_gpu $(BIN)/mul_runs_sp
tuneCpu: $(BIN)/tune_cpu
perf: $(BIN)/large_data_cpu $(BIN)/gpu_performance
comp: $(BIN)/compare_gpu_cpu $(BIN)/compare_gpu_sp $(BIN)/compare_tuners
runSamplers: allSyn allMn
# runSepSamplers: runCpu runGpu runGpuSp runGpuMp
runSepSamplers: runCpu runGpu runGpuSp
runCpu: cpuSyn cpuMn
runGpu: gpuSyn gpuMn
runGpuSp: spSyn spMn
runGpuMp: spSyn spMn
runTests: runMulRuns runPerf runTune runComp
runMulRuns: mulRunsSynthetic mulRunsMnist
runPerf: runLargeCpu runGpuPerf
runTune: runTuneCpu
runComp: runCompSyn runCompMn runCompTun
runCompSyn: runGpuCpuCompSyn runGpuSpCompSyn
runCompMn: runGpuCpuCompMn runGpuSpCompMn
runCompTun: runCompTuners
hostSynthetic:
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/
python $(DATA_SCRIPTS)/synthetic_generation.py -sz 1000 -dim 3 -split 1 -dir host
generateMnist:
rm -rf $(DATA)
mkdir -p $(DATA)
python $(DATA_SCRIPTS)/mnist.py
allSyn: $(BIN)/mcmc_cpu $(BIN)/mcmc_gpu $(BIN)/mcmc_sp
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/synthetic
python $(DATA_SCRIPTS)/synthetic_generation.py -sz 1000 -dim 3 -split 1 -dir host
$(BIN)/mcmc_cpu -d 1 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1
$(BIN)/mcmc_gpu -d 1 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
$(BIN)/mcmc_sp -d 1 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
allMn: $(BIN)/mcmc_cpu $(BIN)/mcmc_gpu $(BIN)/mcmc_sp
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/mnist
python $(DATA_SCRIPTS)/mnist_generation.py -sz 1000 -dim 3 -dir host
$(BIN)/mcmc_cpu -d 2 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1
$(BIN)/mcmc_gpu -d 2 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
$(BIN)/mcmc_sp -d 2 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
cpuSyn: $(BIN)/mcmc_cpu
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/synthetic
python $(DATA_SCRIPTS)/synthetic_generation.py -sz 1000 -dim 3 -split 1 -dir host
$(BIN)/mcmc_cpu -d 1 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1
cpuMn: $(BIN)/mcmc_cpu
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/mnist
python $(DATA_SCRIPTS)/mnist_generation.py -sz 1000 -dim 3 -dir host
$(BIN)/mcmc_cpu -d 2 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1
gpuSyn: $(BIN)/mcmc_gpu
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/synthetic
python $(DATA_SCRIPTS)/synthetic_generation.py -sz 1000 -dim 3 -split 1 -dir host
$(BIN)/mcmc_gpu -d 1 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
gpuMn: $(BIN)/mcmc_gpu
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/mnist
python $(DATA_SCRIPTS)/mnist_generation.py -sz 1000 -dim 3 -dir host
$(BIN)/mcmc_gpu -d 2 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
mpSyn: $(BIN)/mcmc_mp
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/synthetic
python $(DATA_SCRIPTS)/synthetic_generation.py -sz 1024 -dim 3 -split 1 -dir host
$(BIN)/mcmc_mp -d 1 -sz 1024 -dim 3 -samp 1 -burn 1 -lag 500 -tune 0 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
mpMn: $(BIN)/mcmc_mp
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/mnist
python $(DATA_SCRIPTS)/mnist_generation.py -sz 1000 -dim 3 -dir host
$(BIN)/mcmc_mp -d 1 -sz 1000 -dim 3 -samp 1000 -burn 5000 -lag 500 -tune 0 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
spSyn: $(BIN)/mcmc_sp
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/synthetic
python $(DATA_SCRIPTS)/synthetic_generation.py -sz 1000 -dim 3 -split 1 -dir host
$(BIN)/mcmc_sp -d 1 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
spMn: $(BIN)/mcmc_sp
rm -rf $(DATA)/host
mkdir -p $(DATA)/host/ $(OUT)/host/mnist
python $(DATA_SCRIPTS)/mnist_generation.py -sz 1000 -dim 3 -dir host
$(BIN)/mcmc_sp -d 2 -sz 1000 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1 -maxThreads 128 -maxBlocks 64 -kernel 2 -cpuThresh 32
gpuProf: $(BIN)/mcmc_gpu
rm -rf $(OUT)/prof
mkdir -p $(OUT)/prof $(RES)/prof
./$(SH_SCRIPTS)/profiling_gpu.sh
cp -a $(OUT)/prof/. $(RES)/prof
mulRunsSynthetic: $(BIN)/mul_runs_cpu $(BIN)/mul_runs_gpu $(BIN)/mul_runs_sp
rm -rf $(DATA)/runs $(OUT)/runs
mkdir -p $(DATA)/runs $(RES)/runs/out $(OUT)/runs
python $(DATA_SCRIPTS)/synthetic_generation_3d.py -sz 500 -dim 3 -split 1 -dir runs
$(BIN)/mul_runs_cpu -d 1 -sz 500 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1
./$(SH_SCRIPTS)/multiple_runs_gpu.sh
./$(SH_SCRIPTS)/multiple_runs_sp.sh
cp -a $(OUT)/runs/. $(RES)/runs/out
python $(PLOT_SCRIPTS)/hist_plot_runs.py -d 1
mulRunsMnist: $(BIN)/mul_runs_cpu $(BIN)/mul_runs_gpu $(BIN)/mul_runs_sp
rm -rf $(DATA)/runs $(OUT)/runs
mkdir -p $(DATA)/runs $(RES)/runs_mnist/out $(OUT)/runs_mnist
python $(DATA_SCRIPTS)/mnist_generation.py -sz 500 -dim 3 -dir runs
$(BIN)/mul_runs_cpu -d 2 -sz 500 -dim 3 -samp 30000 -burn 10000 -lag 500 -tune 1
./$(SH_SCRIPTS)/multiple_runs_gpu_mnist.sh
./$(SH_SCRIPTS)/multiple_runs_sp_mnist.sh
cp -a $(OUT)/runs_mnist/. $(RES)/runs_mnist/out
python $(PLOT_SCRIPTS)/hist_plot_runs.py -d 2
runTuneCpu: $(BIN)/tune_cpu
rm -rf $(DATA)/tunning_cpu
mkdir -p $(DATA)/tunning_cpu $(OUT)/tunning_cpu $(RES)/tunning_cpu/out
python $(DATA_SCRIPTS)/synthetic_generation_3d.py -sz 500 -dim 3 -split 1 -dir tunning_cpu
$(BIN)/tune_cpu -d 1 -sz 500 -dim 3 -samp 20000 -burn 5000 -lag 500 -tune 1
python $(DATA_SCRIPTS)/mnist_generation.py -sz 500 -dim 3 -dir tunning_cpu
$(BIN)/tune_cpu -d 2 -sz 500 -dim 3 -samp 20000 -burn 5000 -lag 500 -tune 1
cp -a $(OUT)/tunning_cpu/. $(RES)/tunning_cpu/out
python $(PLOT_SCRIPTS)/tunning_cpu.py -d 1
python $(PLOT_SCRIPTS)/tunning_cpu.py -d 2
runLargeCpu: $(BIN)/large_data_cpu
rm -rf $(OUT)/large_data_cpu/
mkdir -p $(OUT)/large_data_cpu/ $(RES)/large_data_cpu/out
./$(SH_SCRIPTS)/large_data_cpu.sh
cp -a $(OUT)/large_data_cpu/. $(RES)/large_data_cpu/out
python $(PLOT_SCRIPTS)/large_data_cpu.py
rm -rf $(DATA)/large_data_cpu
runGpuPerf: $(BIN)/gpu_performance
rm -rf $(OUT)/gpu_performance/
mkdir -p $(OUT)/gpu_performance/ $(RES)/gpu_performance/out
./$(SH_SCRIPTS)/gpu_performance.sh
cp -a $(OUT)/gpu_performance/. $(RES)/gpu_performance/out
python $(PLOT_SCRIPTS)/gpu_performance.py
rm -rf $(DATA)/gpu_performance
runGpuCpuCompSyn: $(BIN)/compare_gpu_cpu
rm -rf $(OUT)/compare_gpu_cpu/
mkdir -p $(OUT)/compare_gpu_cpu/ res/compare_gpu_cpu/out
./$(SH_SCRIPTS)/compare_gpu_cpu.sh
cp -a $(OUT)/compare_gpu_cpu/. $(RES)/compare_gpu_cpu/out
python $(PLOT_SCRIPTS)/compare_implementations.py -v 1 -d 1
rm -rf $(DATA)/compare_gpu_cpu
runGpuSpCompSyn: $(BIN)/compare_gpu_sp
rm -rf $(OUT)/compare_gpu_sp/
mkdir -p $(OUT)/compare_gpu_sp/ $(RES)/compare_gpu_sp/out
./$(SH_SCRIPTS)/compare_gpu_sp.sh
cp -a $(OUT)/compare_gpu_sp/. $(RES)/compare_gpu_sp/out
python $(PLOT_SCRIPTS)/compare_implementations.py -v 2 -d 1
rm -rf $(DATA)/compare_gpu_sp
runGpuCpuCompMn: $(BIN)/compare_gpu_cpu
rm -rf $(OUT)/compare_gpu_cpu_mnist/
mkdir -p $(OUT)/compare_gpu_cpu_mnist/ $(RES)/compare_gpu_cpu_mnist/out
./$(SH_SCRIPTS)/compare_gpu_cpu_mnist.sh
cp -a $(OUT)/compare_gpu_cpu_mnist/. $(RES)/compare_gpu_cpu_mnist/out
python $(PLOT_SCRIPTS)/compare_implementations.py -v 1 -d 2
rm -rf $(DATA)/compare_gpu_cpu
runGpuSpCompMn: $(BIN)/compare_gpu_sp
rm -rf $(OUT)/compare_gpu_sp_mnist/
mkdir -p $(OUT)/compare_gpu_sp_mnist/ $(RES)/compare_gpu_sp_mnist/out
./$(SH_SCRIPTS)/compare_gpu_sp_mnist.sh
cp -a $(OUT)/compare_gpu_sp_mnist/. $(RES)/compare_gpu_sp_mnist/out
python $(PLOT_SCRIPTS)/compare_implementations.py -v 2 -d 2
rm -rf $(DATA)/compare_gpu_sp
runCompTuners: $(BIN)/compare_tuners
rm -rf $(OUT)/compare_tuners/
mkdir -p $(OUT)/compare_tuners/ $(RES)/compare_tuners/out
./$(SH_SCRIPTS)/compare_tuners.sh
cp -a $(OUT)/compare_tuners/. $(RES)/compare_tuners/out
python scr/plot_scr/compare_tuners.py
rm -rf $(DATA)/compare_tuners
mpProf: $(BIN)/mcmc_mp
mkdir -p $(OUT)/prof
nvprof --analysis-metrics -o $(OUT)/prof/small_data_mp.nvprof bin/mcmc_mp -d 1 -sz 1024 -dim 3 -samp 1 -burn 1 -lag 500 -tune 0 -maxThreads 64 -maxBlocks 64 -kernel 2 -cpuThresh 32
clean:
rm -rf $(BIN)
rm -rf $(OBJ)
rm -rf $(OUT)
rm -rf $(DATA)
mkdir -p $(OBJ) $(BIN) $(DATA)
$(BIN)/mcmc_cpu: $(ALL_OBJ) $(CPU_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/mcmc_gpu: $(ALL_OBJ) $(GPU_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/mcmc_sp: $(ALL_OBJ) $(SP_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/mcmc_mp: $(ALL_OBJ) $(MP_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(OBJ)/%.o: %.cu
$(NVCC) $(INCLUDES) $(NVCCFLAGS) $(GENCODE_FLAGS) -o $@ -c $<
$(OBJ)/%.o: %.c
$(GCC) $(INCLUDES) $(GCCFLAGS) -o $@ -c $<
$(BIN)/mul_runs_cpu: $(ALL_OBJ) $(RUNS_CPU_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/mul_runs_gpu: $(ALL_OBJ) $(RUNS_GPU_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/mul_runs_sp: $(ALL_OBJ) $(RUNS_SP_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/tune_cpu: $(ALL_OBJ) $(TUNE_CPU_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/large_data_cpu: $(ALL_OBJ) $(LARGE_DATA_CPU_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/gpu_performance: $(ALL_OBJ) $(GPU_PERFORMANCE_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/compare_gpu_cpu: $(ALL_OBJ) $(GPU_CPU_COMP_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/compare_gpu_sp: $(ALL_OBJ) $(GPU_SP_COMP_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)
$(BIN)/compare_tuners: $(ALL_OBJ) $(TUNERS_CPU_OBJ)
$(NVCC) $^ -o $@ $(LIBRARIES)