1 # Makefile to build all the available variants
3 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
4 TESTSEQ = bag ball1 car1 book
5 TESTFLAGS = default fit128
7 all: $(foreach build,$(BUILDS),build-$(build)/kcf_vot)
11 ## Useful setting - uncomment and modify as needed
12 # CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
13 # CMAKE_OPTS += -DCUDA_VERBOSE_BUILD=ON -DCUDA_NVCC_FLAGS="--verbose;--save-temps"
16 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
18 CMAKE_OTPS_opencvfft-st = -DFFT=OpenCV
19 CMAKE_OTPS_opencvfft-async = -DFFT=OpenCV -DASYNC=ON
20 CMAKE_OTPS_opencvfft-openmp = -DFFT=OpenCV -DOPENMP=ON
21 CMAKE_OTPS_fftw = -DFFT=fftw
22 CMAKE_OTPS_fftw-openmp = -DFFT=fftw -DOPENMP=ON
23 CMAKE_OTPS_fftw-async = -DFFT=fftw -DASYNC=ON
24 CMAKE_OTPS_fftw-big = -DFFT=fftw -DBIG_BATCH=ON
25 CMAKE_OTPS_fftw-big-openmp = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
26 CMAKE_OTPS_cufftw = -DFFT=cuFFTW
27 CMAKE_OTPS_cufftw-big = -DFFT=cuFFTW -DBIG_BATCH=ON
28 CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW -DBIG_BATCH=ON -DOPENMP=ON
29 CMAKE_OTPS_cufft = -DFFT=cuFFT
30 CMAKE_OTPS_cufft-openmp = -DFFT=cuFFT -DOPENMP=ON
31 CMAKE_OTPS_cufft-big = -DFFT=cuFFT -DBIG_BATCH=ON
32 CMAKE_OTPS_cufft-big-openmp = -DFFT=cuFFT -DBIG_BATCH=ON -DOPENMP=ON
34 .SECONDARY: $(BUILDS:%=build-%/build.ninja)
37 @echo '############################################################'
39 cd $(@D) && cmake $(CMAKE_OPTS) $(CMAKE_OTPS_$*) ..
42 build-%/kcf_vot: build-%/build.ninja $(shell git ls-files)
43 @echo '############################################################'
46 $(BUILDS): %: build-%/kcf_vot
49 rm -rf $(BUILDS:%=build-%)
51 ##########################
53 ##########################
55 print-test-results = grep ^Average $(1)|sed -E -e "s|build-(.*)/kcf_vot-(.*).log:|\2;\1;|"|sort|column -t -s";"
57 test: $(BUILDS:%=test-%)
58 @echo; echo "Summary test results:"
59 @$(call print-test-results,$(foreach build,$(BUILDS),\
60 $(foreach seq,$(TESTSEQ),\
61 $(foreach f,$(TESTFLAGS),build-$(build)/kcf_vot-$(seq)-$(f).log))))
63 $(BUILDS:%=test-%): test-%:
64 @$(call print-test-results,$(foreach seq,$(TESTSEQ),\
65 $(foreach f,$(TESTFLAGS),build-$*/kcf_vot-$(seq)-$(f).log)))
67 # Usage: testcase <build> <seq>
69 test-$(1): test-$(1)-$(2)
70 test-$(1)-$(2): $(foreach f,$(TESTFLAGS),build-$(1)/kcf_vot-$(2)-$(f).log)
71 $(foreach f,$(TESTFLAGS),build-$(1)/kcf_vot-$(2)-$(f).log): build-$(1)/kcf_vot $$(filter-out %/output.txt,$$(wildcard vot2016/$(2)/*)) | vot2016/$(2)
72 $$< $$(if $$(@:%fit128.log=),,--fit=128) vot2016/$(2) > $$@
73 $(if $(TRAVIS),,cat $$@)
76 $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(eval $(call testcase,$(build),$(seq)))))
78 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
79 unzip -d vot2016 -q $^
80 for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
82 .INTERMEDIATE: vot2016.zip
83 .SECONDARY: vot2016.zip
85 wget http://data.votchallenge.net/vot2016/vot2016.zip
91 # Building all $(BUILDS) with make is slow, even when run with in
92 # parallel (make -j). The target below generates build.ninja file that
93 # compiles all variants in the same ways as this makefile, but faster.
94 # The down side is that the build needs about 10 GB of memory.
105 echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
108 # Ninja generator - to have faster parallel builds and tests
111 @$(call echo,>$@,$(ninja-rule))
112 @$(foreach build,$(BUILDS),\
113 $(call echo,>>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
114 @$(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),\
115 $(call echo,>>$@,$(call ninja-testcase,$(build),$(seq),$(f)))$(nl))))
116 @$(call echo,>>$@,build test: print_results $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))))
117 @$(foreach build,$(BUILDS),$(call echo,>>$@,build test-$(build): print_results $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))))
118 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build test-$(seq): print_results $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))))
119 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): make))
124 command = cd $$$$(dirname $$out) && cmake $(CMAKE_OPTS) $$opts ..
125 description = CMake $$out
127 # Absolute path in -C allows Emacs to properly jump to error message locations
128 command = ninja -C `realpath $$$$(dirname $$out)`
129 description = Ninja $$out
131 command = build-$$build/kcf_vot $$flags $$seq > $$out
133 description = Print results
134 command = $(call print-test-results,$$in)
140 build build-$(1)/build.ninja: cmake
142 build build-$(1)/kcf_vot: ninja build-$(1)/build.ninja build.ninja
143 default build-$(1)/kcf_vot
146 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
148 # Usage: ninja-testcase <build> <seq> <flags>
149 define ninja-testcase
150 build build-$(1)/kcf_vot-$(2)-$(3).log: test_seq build-$(1)/kcf_vot $(filter-out %/output.txt,$(wildcard vot2016/$(2)/*)) || vot2016/$(2)
153 flags = $(if $(3:fit128=),,--fit=128)