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
12 $(BUILDS): build.ninja
13 ninja build-$@/build.ninja
19 CMAKE_OPTS += -G Ninja
21 ## Useful setting - uncomment and modify as needed
22 # CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
23 # CMAKE_OPTS += -DCUDA_VERBOSE_BUILD=ON -DCUDA_NVCC_FLAGS="--verbose;--save-temps"
26 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
27 # export CUDA_ARCH_LIST=6.2
29 CMAKE_OTPS_opencvfft-st = -DFFT=OpenCV
30 CMAKE_OTPS_opencvfft-async = -DFFT=OpenCV -DASYNC=ON
31 CMAKE_OTPS_opencvfft-openmp = -DFFT=OpenCV -DOPENMP=ON
32 CMAKE_OTPS_fftw = -DFFT=fftw
33 CMAKE_OTPS_fftw-openmp = -DFFT=fftw -DOPENMP=ON
34 CMAKE_OTPS_fftw-async = -DFFT=fftw -DASYNC=ON
35 CMAKE_OTPS_fftw-big = -DFFT=fftw -DBIG_BATCH=ON
36 CMAKE_OTPS_fftw-big-openmp = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
37 CMAKE_OTPS_cufftw = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
38 CMAKE_OTPS_cufftw-big = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
39 CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
40 CMAKE_OTPS_cufft = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)')
41 CMAKE_OTPS_cufft-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DOPENMP=ON
42 CMAKE_OTPS_cufft-big = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON
43 CMAKE_OTPS_cufft-big-openmp = -DFFT=cuFFT $(if $(CUDA_ARCH_LIST),-DCUDA_ARCH_LIST='$(CUDA_ARCH_LIST)') -DBIG_BATCH=ON -DOPENMP=ON
45 ##########################
47 ##########################
49 test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
52 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
53 unzip -d vot2016 -q $^
54 for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
56 .INTERMEDIATE: vot2016.zip
57 .SECONDARY: vot2016.zip
59 wget -O $@ http://data.votchallenge.net/vot2016/vot2016.zip
65 # Building all $(BUILDS) with make is slow, even when run with in
66 # parallel (make -j). The target below generates build.ninja file that
67 # compiles all variants in the same ways as this makefile, but faster.
68 # The down side is that the build needs about 10 GB of memory.
75 # Define echo depending on whether make supports the $(file) function.
77 ifneq ($(wildcard .test.file),)
78 echo = $(file $(1),$(2))
80 echo = echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
83 # Ninja generator - to have faster parallel builds and tests
87 @$(call echo,>$@,$(ninja-rule))
88 @$(foreach build,$(BUILDS),\
89 $(call echo,>>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
90 @$(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),\
91 $(call echo,>>$@,$(call ninja-testcase,$(build),$(seq),$(f)))$(nl))))
92 @$(call echo,>>$@,build test: PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))) | print-test-results)
93 @$(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))
94 @$(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))
95 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): MAKE))
97 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
101 command = make $$out BUILDS="$(BUILDS)" TESTSEQ="$(TESTSEQ)" TESTFLAGS="$(TESTFLAGS)"
104 command = cd $$$$(dirname $$out) && cmake $(CMAKE_OPTS) $$opts ..
106 # Absolute path in -C allows Emacs to properly jump to error message locations
107 command = ninja -C $(CURDIR)/$$$$(dirname $$out)
108 description = ninja $$out
111 # Errors are ignored - they will be reported by PRINT_RESULTS
112 command = build-$$build/kcf_vot $$flags $$seq > $$out || :
114 description = Print results
115 command = ./wvtool -w125 -v run ./print-test-results $$in
122 # command = /usr/bin/ninja -t clean -r NINJA
123 description = Cleaning all built files...
124 command = rm -rf $(BUILDS:%=build-%)
126 build build.ninja: REGENERATE Makefile
129 GIT_LS_FILES := $(shell git ls-files)
132 build build-$(1)/build.ninja: CMAKE
134 build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(GIT_LS_FILES)
135 default build-$(1)/kcf_vot
138 # Usage: ninja-testcase <build> <seq> <flags>
139 define ninja-testcase
140 build build-$(1)/kcf_vot-$(2)-$(3).log: TEST_SEQ build-$(1)/kcf_vot $(filter-out %/output.txt,$(wildcard vot2016/$(2)/*)) vot2016/$(2)
143 flags = $(if $(3:fit128=),,--fit=128)