include common/make.config

RODINIA_BASE_DIR := $(shell pwd)

OPENCL_BIN_DIR := $(RODINIA_BASE_DIR)/bin/linux/opencl

OCL_DIRS  := backprop bfs cfd dwt2d gaussian heartwall hybridsort hotspot kmeans lavaMD leukocyte lud nn nw srad streamcluster particlefilter pathfinder

all: OPENCL

OPENCL:
	cd opencl/backprop;			make;	cp backprop $(OPENCL_BIN_DIR)
	cd opencl/bfs;				make;	cp bfs	    $(OPENCL_BIN_DIR)
	cd opencl/cfd;				make;	cp euler3d	$(OPENCL_BIN_DIR)
	cd opencl/hotspot;			make;	cp hotspot	$(OPENCL_BIN_DIR)
	cd opencl/kmeans;			make;	cp kmeans	$(OPENCL_BIN_DIR)
	cd opencl/lavaMD;			make;	cp lavaMD	$(OPENCL_BIN_DIR)
	cd opencl/leukocyte;		make;	cp OpenCL/leukocyte	$(OPENCL_BIN_DIR)
	cd opencl/lud/ocl;			make;	cp lud		$(OPENCL_BIN_DIR)
	cd opencl/nw;				make;	cp nw		$(OPENCL_BIN_DIR)
	cd opencl/srad;				make; 	cp srad		$(OPENCL_BIN_DIR)
	cd opencl/streamcluster;	make;	cp streamcluster	$(OPENCL_BIN_DIR)
	cd opencl/pathfinder;		make;	cp pathfinder	$(OPENCL_BIN_DIR)
	cd opencl/particlefilter;	make;	cp OCL_particlefilter_naive OCL_particlefilter_single OCL_particlefilter_double $(OPENCL_BIN_DIR)
	cd opencl/gaussian;			make;	cp gaussian	$(OPENCL_BIN_DIR)
	cd opencl/nn;				make;	cp nn	$(OPENCL_BIN_DIR)
	cd opencl/heartwall;		make;	cp heartwall	$(OPENCL_BIN_DIR)
	cd opencl/hybridsort;       make;   cp hybridsort $(OPENCL_BIN_DIR)
	cd opencl/dwt2d;            make;   cp dwt2d  $(OPENCL_BIN_DIR)

OPENCL_BENCHMARK_GPU:
	./time-and-save.sh opencl/backprop times.dat gpu
	./time-and-save.sh opencl/bfs times.dat gpu
	./time-and-save.sh opencl/cfd times.dat gpu
	./time-and-save.sh opencl/hotspot times.dat gpu
	./time-and-save.sh opencl/kmeans times.dat gpu
	./time-and-save.sh opencl/lavaMD times.dat gpu
	./time-and-save.sh opencl/leukocyte/OpenCL times.dat gpu
	./time-and-save.sh opencl/lud/ocl times.dat gpu
	./time-and-save.sh opencl/nw times.dat gpu
	./time-and-save.sh opencl/srad times.dat gpu
	./time-and-save.sh opencl/streamcluster times.dat gpu
	./time-and-save.sh opencl/pathfinder times.dat gpu
	./time-and-save.sh opencl/particlefilter times.dat gpu
	./time-and-save.sh opencl/gaussian times.dat gpu
	./time-and-save.sh opencl/nn times.dat gpu
	./time-and-save.sh opencl/heartwall times.dat gpu
	./time-and-save.sh opencl/hybridsort times.dat gpu
	./time-and-save.sh opencl/dwt2d times.dat gpu

clean: OCL_clean OPENCL_BENCHMARK_clean

OCL_clean:
	cd $(OPENCL_BIN_DIR); rm -f *
	for dir in $(OCL_DIRS) ; do cd opencl/$$dir ; make clean ; cd ../.. ; done

OPENCL_BENCHMARK_clean:
	rm -r power-usage.csv results
