]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blob - Makefile
test: Report bad accuracy as ACCURACY rather than BAD
[hercules2020/kcf.git] / Makefile
1 # Makefile to build all the available variants
2
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
6
7 all: $(BUILDS)
8
9 ninja: build.ninja
10         ninja
11
12 $(BUILDS): build.ninja
13         ninja build-$@/build.ninja
14         ninja -C build-$@
15
16 clean: build.ninja
17         ninja $@
18
19 CMAKE_OPTS += -G Ninja
20
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"
24 # export CC=gcc-5
25 # export CXX=g++-5
26 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
27 # export CUDA_ARCH_LIST=6.2
28
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
44
45 ##########################
46 ### Tests
47 ##########################
48
49 test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
50         ninja $@
51
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
55
56 .INTERMEDIATE: vot2016.zip
57 .SECONDARY:    vot2016.zip
58 vot2016.zip:
59         wget --progress=dot:giga -O $@ http://data.votchallenge.net/vot2016/vot2016.zip
60
61 ###################
62 # Ninja generator #
63 ###################
64
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.
69
70
71 # Define echo depending on whether make supports the $(file) function.
72 $(file >.test.file)
73 ifneq ($(wildcard .test.file),)
74   echo = $(file $(1),$(2))
75 else
76   define nl
77
78
79   endef
80   echo = echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
81 endif
82
83 # Ninja generator - to have faster parallel builds and tests
84 .PHONY: build.ninja
85
86 build.ninja:: $(MAKEFILE_LIST)
87         @echo "Generating $@"
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))))) | print-test-results)
94         @$(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))
95         @$(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))
96         @$(foreach seq,$(TESTSEQ),$(call echo,>>$@,build vot2016/$(seq): MAKE))
97
98 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
99
100 define ninja-rule
101 rule REGENERATE
102   command = MAKEFLAGS='$(MAKEFLAGS)' $(MAKE) $$out
103   description = Regenerating $$out
104   generator = 1
105 rule CMAKE
106   command = cd $$subdir && cmake $(CMAKE_OPTS) $$opts ..
107 rule NINJA
108   # Absolute path in -C allows Emacs to properly jump to error message locations
109   command = ninja -C $(CURDIR)/$$subdir
110   restat = 1
111 rule TEST_SEQ
112   # Errors are ignored - they will be reported by PRINT_RESULTS
113   command = build-$$build/kcf_vot $$flags $$seq $(if $(TRAVIS),2>&1) >$$out $(if $(TRAVIS),| grep -v libdc1394) || :
114 rule PRINT_RESULTS
115   description = Print results
116   command = ./wvtool -w125 -v run ./print-test-results $$in
117 rule MAKE
118   command = make $$out
119   pool = make
120 pool make
121   depth = 1
122 rule CLEAN
123 #  command = /usr/bin/ninja -t clean -r NINJA
124   description = Cleaning all built files...
125   command = rm -rf $(BUILDS:%=build-%)
126 build clean: CLEAN
127 build build.ninja: REGENERATE $(MAKEFILE_LIST)
128 endef
129
130 GIT_LS_FILES := $(shell git ls-files)
131
132 define ninja-build
133 build build-$(1)/build.ninja: CMAKE
134   opts = $(2)
135   subdir = build-$(1)
136 build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(GIT_LS_FILES)
137   subdir = build-$(1)
138 default build-$(1)/kcf_vot
139 endef
140
141 # Usage: ninja-testcase <build> <seq> <flags>
142 define ninja-testcase
143 build build-$(1)/kcf_vot-$(2)-$(3).log: TEST_SEQ build-$(1)/kcf_vot $(filter-out %/output.txt,$(wildcard vot2016/$(2)/*)) vot2016/$(2)
144   build = $(1)
145   seq = vot2016/$(2)
146   flags = $(if $(3:fit128=),,--fit=128)
147 endef