]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blob - Makefile
Really ignore test failures
[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 print_%:
10         @$(foreach v,$($*),echo $(v);)
11
12 ninja: build.ninja
13         ninja
14
15 $(BUILDS): build.ninja
16         ninja build-$@/build.ninja
17         ninja -C build-$@
18
19 clean: build.ninja
20         ninja $@
21
22 CMAKE_OPTS += -G Ninja
23
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"
27 # export CC=gcc-5
28 # export CXX=g++-5
29 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
30 # export CUDA_ARCH_LIST=6.2
31
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
47
48 ##########################
49 ### Tests
50 ##########################
51
52 test $(BUILDS:%=test-%) $(SEQ:%=test-%): build.ninja
53         ninja $@
54
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
58
59 .INTERMEDIATE: vot2016.zip
60 .SECONDARY:    vot2016.zip
61 vot2016.zip:
62         wget --progress=dot:giga -O $@ http://data.votchallenge.net/vot2016/vot2016.zip
63
64 ###################
65 # Ninja generator #
66 ###################
67
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.
72
73
74 # Define echo depending on whether make supports the $(file) function.
75 $(file >.test.file)
76 ifneq ($(wildcard .test.file),)
77   echo = $(file $(1),$(2))
78 else
79   define nl
80
81
82   endef
83   echo = echo $(1) '$(subst $(nl),\n,$(subst \,\\,$(2)))';
84 endif
85
86 # Ninja generator - to have faster parallel builds and tests
87 .PHONY: build.ninja
88
89 build.ninja:: $(MAKEFILE_LIST)
90         @echo "Generating $@"
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))
103
104 ninja-test = build-$(1)/kcf_vot-$(2)-$(3).log
105
106 define ninja-rule
107 rule REGENERATE
108   command = MAKEFLAGS='$(MAKEFLAGS)' $(MAKE) $$out
109   description = Regenerating $$out
110   generator = 1
111 rule CMAKE
112   command = cd $$subdir && cmake $(CMAKE_OPTS) $$opts ..
113 rule NINJA
114   # Absolute path in -C allows Emacs to properly jump to error message locations
115   command = ninja -C $(CURDIR)/$$subdir
116   restat = 1
117 rule TEST_SEQ
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
120 rule PRINT_RESULTS
121   description = Print results
122   command = ./wvtool -w125 -v run ./print-test-results $$in
123 rule PLOT_RESULTS
124   description = Plot results
125   command = ./graphGen.sh -f -s $$in
126 rule MAKE
127   command = make $$out
128   pool = make
129 pool make
130   depth = 1
131 rule CLEAN
132 #  command = /usr/bin/ninja -t clean -r NINJA
133   description = Cleaning all built files...
134   command = rm -rf $(BUILDS:%=build-%)
135 build clean: CLEAN
136 build build.ninja: REGENERATE $(MAKEFILE_LIST)
137 endef
138
139 GIT_LS_FILES := $(shell git ls-files)
140
141 define ninja-build
142 build build-$(1)/build.ninja: CMAKE
143   opts = $(2)
144   subdir = build-$(1)
145 build build-$(1)/kcf_vot: NINJA build-$(1)/build.ninja $(GIT_LS_FILES)
146   subdir = build-$(1)
147 default build-$(1)/kcf_vot
148 endef
149
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)
153   build = $(1)
154   seq = vot2016/$(2)
155   flags = $(if $(3:fit128=),,--fit=128)
156 endef