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 print-test-results = grep ^Average $(1)|sed -E -e "s|build-(.*)/kcf_vot-(.*).log:|\2;\1;|"|sort|column -t -s";"
51 test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
54 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
55 unzip -d vot2016 -q $^
56 for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
58 .INTERMEDIATE: vot2016.zip
59 .SECONDARY: vot2016.zip
61 wget http://data.votchallenge.net/vot2016/vot2016.zip
67 # Building all $(BUILDS) with make is slow, even when run with in
68 # parallel (make -j). The target below generates build.ninja file that
69 # compiles all variants in the same ways as this makefile, but faster.
70 # The down side is that the build needs about 10 GB of memory.
78 echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
81 # Ninja generator - to have faster parallel builds and tests
82 .PHONY: build.ninja build.ninja.new
84 build.ninja: build.ninja.new
85 @cmp -s $@ $< || mv -v $< $@
88 @$(call echo,>$@,$(ninja-rule))
89 @$(foreach build,$(BUILDS),\
90 $(call echo,>>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
91 @$(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),\
92 $(call echo,>>$@,$(call ninja-testcase,$(build),$(seq),$(f)))$(nl))))
93 @$(call echo,>>$@,build test: PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))))
94 @$(foreach build,$(BUILDS),$(call echo,>>$@,build test-$(build): PRINT_RESULTS $(foreach seq,$(TESTSEQ),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))))
95 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build test-$(seq): PRINT_RESULTS $(foreach build,$(BUILDS),$(foreach f,$(TESTFLAGS),$(call ninja-test,$(build),$(seq),$(f))))))
96 @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): MAKE))
101 command = cd $$$$(dirname $$out) && cmake $(CMAKE_OPTS) $$opts ..
103 # Absolute path in -C allows Emacs to properly jump to error message locations
104 command = ninja -C `realpath $$$$(dirname $$out)` && touch $$out
105 description = Ninja $$out
107 command = build-$$build/kcf_vot $$flags $$seq > $$out
109 description = Print results
110 command = $(call print-test-results,$$in)
114 # command = /usr/bin/ninja -t clean -r NINJA
115 description = Cleaning all built files...
116 command = rm -rf $(BUILDS:%=build-%)
121 build build-$(1)/build.ninja: CMAKE
123 build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(shell git ls-files)
124 default build-$(1)/kcf_vot
127 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
129 # Usage: ninja-testcase <build> <seq> <flags>
130 define ninja-testcase
131 build build-$(1)/kcf_vot-$(2)-$(3).log: TEST_SEQ build-$(1)/kcf_vot $(filter-out %/output.txt,$(wildcard vot2016/$(2)/*)) || vot2016/$(2)
134 flags = $(if $(3:fit128=),,--fit=128)