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
10 @$(foreach v,$($*),echo $(v);)
15 $(BUILDS): build.ninja
16 ninja build-$@/build.ninja
22 CMAKE_OPTS += -G Ninja
24 ## Useful setting - uncomment and modify as needed
25 # CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
26 # CMAKE_OPTS += -DCUDA_VERBOSE_BUILD=ON -DCUDA_NVCC_FLAGS="--verbose;--save-temps"
29 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
30 # export CUDA_ARCH_LIST=6.2
32 CMAKE_OTPS_opencvfft-st = -DFFT=OpenCV
33 CMAKE_OTPS_opencvfft-async = -DFFT=OpenCV -DASYNC=ON
34 CMAKE_OTPS_opencvfft-openmp = -DFFT=OpenCV -DOPENMP=ON
35 CMAKE_OTPS_fftw = -DFFT=fftw
36 CMAKE_OTPS_fftw-openmp = -DFFT=fftw -DOPENMP=ON
37 CMAKE_OTPS_fftw-async = -DFFT=fftw -DASYNC=ON
38 CMAKE_OTPS_fftw-big = -DFFT=fftw -DBIG_BATCH=ON
39 CMAKE_OTPS_fftw-big-openmp = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
40 CMAKE_OTPS_cufftw = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
41 CMAKE_OTPS_cufftw-big = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
42 CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
43 CMAKE_OTPS_cufft = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
44 CMAKE_OTPS_cufft-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DOPENMP=ON
45 CMAKE_OTPS_cufft-big = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
46 CMAKE_OTPS_cufft-big-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
48 ##########################
50 ##########################
52 test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
55 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
56 unzip -d vot2016 -q $^
57 for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
59 .INTERMEDIATE: vot2016.zip
60 .SECONDARY: vot2016.zip
62 wget --progress=dot:giga -O $@ http://data.votchallenge.net/vot2016/vot2016.zip
68 # Building all $(BUILDS) with make is slow, even when run with in
69 # parallel (make -j). The target below generates build.ninja file that
70 # compiles all variants in the same ways as this makefile, but faster.
71 # The down side is that the build needs about 10 GB of memory.
74 # Define echo depending on whether make supports the $(file) function.
76 ifneq ($(wildcard .test.file),)
77 echo = $(file $(1),$(2))
83 echo = echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
86 # Ninja generator - to have faster parallel builds and tests
89 build.ninja:: $(MAKEFILE_LIST)
91 @$(call echo,>$@,$(ninja-rule))
92 @$(foreach build,$(BUILDS),\
93 $(call echo,>>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
94 @$(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),\
95 $(call echo,>>$@,$(call ninja-testcase,$(build),$(seq),$(f)))$(nl))))
96 @$(call echo,>>$@,build test: PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | print-test-results)
97 @$(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))
98 @$(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))
99 @$(call echo,>>$@,build plot: PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | graphGen.sh)
100 @$(foreach build,$(BUILDS),$(call echo,>>$@,build plot-$(build): PLOT_RESULTS $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
101 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build plot-$(seq): PLOT_RESULTS $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f)))) | graphGen.sh))
102 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): MAKE))
104 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
108 command = MAKEFLAGS='$(MAKEFLAGS)' $(MAKE) $$out
109 description = Regenerating $$out
112 command = cd $$subdir && cmake $(CMAKE_OPTS) $$opts ..
114 # Absolute path in -C allows Emacs to properly jump to error message locations
115 command = ninja -C $(CURDIR)/$$subdir
118 # Errors are ignored - they will be reported by PRINT_RESULTS
119 command = build-$$build/kcf_vot $$flags $$seq $(if $(TRAVIS),2>&1) >$$out $(if $(TRAVIS),| grep -v libdc1394); true
121 description = Print results
122 command = ./wvtool -w125 -v run ./print-test-results $$in
124 description = Plot results
125 command = ./graphGen.sh -f -s $$in
132 # command = /usr/bin/ninja -t clean -r NINJA
133 description = Cleaning all built files...
134 command = rm -rf $(BUILDS:%=build-%)
136 build build.ninja: REGENERATE $(MAKEFILE_LIST)
139 GIT_LS_FILES := $(shell git ls-files)
142 build build-$(1)/build.ninja: CMAKE
145 build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(GIT_LS_FILES)
147 default build-$(1)/kcf_vot
150 # Usage: ninja-testcase <build> <seq> <flags>
151 define ninja-testcase
152 build build-$(1)/kcf_vot-$(2)-$(3).log: TEST_SEQ build-$(1)/kcf_vot $(filter-out %/output.txt,$(wildcard vot2016/$(2)/*)) vot2016/$(2)
155 flags = $(if $(3:fit128=),,--fit=128)