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 = bmx ball1 crossing racing book
5 TESTFLAGS = default fit128
10 @$(foreach v,$($*),echo $(v);)
15 $(BUILDS): build.ninja
16 ninja build-$@/build.ninja
22 ## Useful setting - uncomment and modify as needed
23 # CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
24 # CMAKE_OPTS += -DCUDA_VERBOSE_BUILD=ON -DCUDA_NVCC_FLAGS="--verbose;--save-temps"
27 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
28 # export CUDA_ARCH_LIST=6.2
30 CMAKE_OTPS_opencvfft-st = -DFFT=OpenCV
31 CMAKE_OTPS_opencvfft-async = -DFFT=OpenCV -DASYNC=ON
32 CMAKE_OTPS_opencvfft-openmp = -DFFT=OpenCV -DOPENMP=ON
33 CMAKE_OTPS_fftw = -DFFT=fftw
34 CMAKE_OTPS_fftw-openmp = -DFFT=fftw -DOPENMP=ON
35 CMAKE_OTPS_fftw-async = -DFFT=fftw -DASYNC=ON
36 CMAKE_OTPS_fftw-big = -DFFT=fftw -DBIG_BATCH=ON
37 CMAKE_OTPS_fftw-big-openmp = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
38 CMAKE_OTPS_cufftw = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
39 CMAKE_OTPS_cufftw-big = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
40 CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
41 CMAKE_OTPS_cufft = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
42 CMAKE_OTPS_cufft-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DOPENMP=ON
43 CMAKE_OTPS_cufft-big = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
44 CMAKE_OTPS_cufft-big-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
46 ##########################
48 ##########################
50 test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
53 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
54 unzip -d vot2016 -q $^
55 for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
57 .INTERMEDIATE: vot2016.zip
58 .SECONDARY: vot2016.zip
60 wget --progress=dot:giga -O $@ http://data.votchallenge.net/vot2016/vot2016.zip
66 # Building all $(BUILDS) with make is slow, even when run with in
67 # parallel (make -j). The target below generates build.ninja file that
68 # compiles all variants in the same ways as this makefile, but faster.
69 # The down side is that the build needs about 10 GB of memory.
72 # Define echo depending on whether make supports the $(file) function.
74 ifneq ($(wildcard .test.file),)
75 echo = $(file $(1),$(2))
81 echo = echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
84 # Ninja generator - to have faster parallel builds and tests
87 build.ninja:: $(MAKEFILE_LIST)
89 @$(call echo,>$@,$(ninja-rule))
90 @$(foreach build,$(BUILDS),\
91 $(call echo,>>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
92 @$(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),\
93 $(call echo,>>$@,$(call ninja-testcase,$(build),$(seq),$(f)))$(nl))))
94 @$(call echo,>>$@,build test: PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | print-test-results)
95 @$(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))
96 @$(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))
97 @$(call echo,>>$@,build plot: PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | graphGen.sh)
98 @$(foreach build,$(BUILDS),$(call echo,>>$@,build plot-$(build): PLOT_RESULTS $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
99 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build plot-$(seq): PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
100 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): MAKE))
102 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
106 command = MAKEFLAGS='$(MAKEFLAGS)' $(MAKE) $$out
107 description = Regenerating $$out
110 command = cd $$subdir && cmake -G Ninja $(CMAKE_OPTS) $$opts ..
112 # Absolute path in -C allows Emacs to properly jump to error message locations
113 command = ninja -C $(CURDIR)/$$subdir
116 # Errors are ignored - they will be reported by PRINT_RESULTS
117 command = build-$$build/kcf_vot $$flags $$seq $(if $(TRAVIS),2>&1) >$$out $(if $(TRAVIS),| grep -v libdc1394); true
119 description = Print results
120 command = ./wvtool -w131 -v run ./print-test-results $$in
122 description = Plot results
123 command = ./graphGen.sh -f -s $$in
130 # command = /usr/bin/ninja -t clean -r NINJA
131 description = Cleaning all built files...
132 command = rm -rf $(BUILDS:%=build-%)
134 build build.ninja: REGENERATE $(MAKEFILE_LIST)
137 GIT_LS_FILES := $(shell git ls-files)
140 build build-$(1)/build.ninja: CMAKE
143 build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(GIT_LS_FILES)
145 default build-$(1)/kcf_vot
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)