forked from vojirt/kcf
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
154 lines (129 loc) · 6.16 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
# Makefile to build all the available variants
BUILDS = opencvfft-st opencvfft-async opencvfft-openmp fftw fftw-async fftw-openmp fftw-big fftw-big-openmp cufftw cufftw-big cufftw-big-openmp cufft cufft-openmp cufft-big cufft-big-openmp
TESTSEQ = bmx ball1 crossing racing book
TESTFLAGS = default fit
all: $(BUILDS)
print_%:
@$(foreach v,$($*),echo $(v);)
ninja: build.ninja
ninja
$(BUILDS): build.ninja
ninja build-$@/build.ninja
ninja -C $(CURDIR)/build-$@
clean: build.ninja
ninja $@
## Useful setting - uncomment and modify as needed
# CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
# CMAKE_OPTS += -DCUDA_VERBOSE_BUILD=ON -DCUDA_NVCC_FLAGS="--verbose;--save-temps"
# export CC=gcc-5
# export CXX=g++-5
# export CUDA_BIN_PATH=/usr/local/cuda-9.0
# export CUDA_ARCH_LIST=6.2
CMAKE_OTPS_opencvfft-st = -DFFT=OpenCV
CMAKE_OTPS_opencvfft-async = -DFFT=OpenCV -DASYNC=ON
CMAKE_OTPS_opencvfft-openmp = -DFFT=OpenCV -DOPENMP=ON
CMAKE_OTPS_fftw = -DFFT=fftw
CMAKE_OTPS_fftw-openmp = -DFFT=fftw -DOPENMP=ON
CMAKE_OTPS_fftw-async = -DFFT=fftw -DASYNC=ON
CMAKE_OTPS_fftw-big = -DFFT=fftw -DBIG_BATCH=ON
CMAKE_OTPS_fftw-big-openmp = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
CMAKE_OTPS_cufftw = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
CMAKE_OTPS_cufftw-big = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
CMAKE_OTPS_cufft = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
CMAKE_OTPS_cufft-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DOPENMP=ON
CMAKE_OTPS_cufft-big = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
CMAKE_OTPS_cufft-big-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
##########################
### Tests
##########################
test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
ninja $@
vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
unzip -d vot2016 -q $^
for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
.INTERMEDIATE: vot2016.zip
.SECONDARY: vot2016.zip
vot2016.zip:
wget --progress=dot:giga -O $@ http://rtime.felk.cvut.cz/~sojka/download/vot2016.zip
###################
# Ninja generator #
###################
# Building all $(BUILDS) with make is slow, even when run with in
# parallel (make -j). The target below generates build.ninja file that
# compiles all variants in the same ways as this makefile, but faster.
# The down side is that the build needs about 10 GB of memory.
# Define echo depending on whether make supports the $(file) function.
$(file >.test.file)
ifneq ($(wildcard .test.file),)
echo = $(file $(1),$(2))
else
define nl
endef
echo = echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
endif
# Ninja generator - to have faster parallel builds and tests
.PHONY: build.ninja
build.ninja:: $(MAKEFILE_LIST)
@echo "Generating $@"
@$(call echo,>$@,$(ninja-rule))
@$(foreach build,$(BUILDS),\
$(call echo,>>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
@$(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),\
$(call echo,>>$@,$(call ninja-testcase,$(build),$(seq),$(f)))$(nl))))
@$(call echo,>>$@,build test: PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | print-test-results)
@$(foreach build,$(BUILDS),$(call echo,>>$@,build test-$(build): PRINT_RESULTS $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | print-test-results))
@$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build test-$(seq): PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | print-test-results))
@$(call echo,>>$@,build plot: PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | graphGen.sh)
@$(foreach build,$(BUILDS),$(call echo,>>$@,build plot-$(build): PLOT_RESULTS $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
@$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build plot-$(seq): PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
@$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): MAKE))
ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
define ninja-rule
rule REGENERATE
command = MAKEFLAGS='$(MAKEFLAGS)' $(MAKE) $$out
description = Regenerating $$out
generator = 1
rule CMAKE
command = cd $$subdir && cmake -G Ninja $(CMAKE_OPTS) $$opts ..
rule NINJA
# Absolute path in -C allows Emacs to properly jump to error message locations
command = ninja -C $(CURDIR)/$$subdir
restat = 1
rule TEST_SEQ
# Errors are ignored - they will be reported by PRINT_RESULTS
command = build-$$build/kcf_vot $$flags $$seq >$$out; true
rule PRINT_RESULTS
description = Print results
command = ./wvtool -w120 -v run ./print-test-results $$in
rule PLOT_RESULTS
description = Plot results
command = ./graphGen.sh -f -s $$in
rule MAKE
command = make $$out
pool = make
pool make
depth = 1
rule CLEAN
# command = /usr/bin/ninja -t clean -r NINJA
description = Cleaning all built files...
command = rm -rf $(BUILDS:%=build-%)
build clean: CLEAN
build build.ninja: REGENERATE $(MAKEFILE_LIST)
endef
GIT_LS_FILES := $(shell git ls-files)
define ninja-build
build build-$(1)/build.ninja: CMAKE
opts = $(2)
subdir = build-$(1)
build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(GIT_LS_FILES)
subdir = build-$(1)
default build-$(1)/kcf_vot
endef
# Usage: ninja-testcase <build> <seq> <flags>
define ninja-testcase
build build-$(1)/kcf_vot-$(2)-$(3).log: TEST_SEQ build-$(1)/kcf_vot $(filter-out %/output.txt,$(wildcard vot2016/$(2)/*)) vot2016/$(2)
build = $(1)
seq = vot2016/$(2)
flags = $(if $(3:fit128=),,--fit=128)$(if $(3:fit=),,--fit)
endef