]> rtime.felk.cvut.cz Git - hercules2020/kcf.git/blob - Makefile
Merge branch 'master' into rotation
[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: $(foreach build,$(BUILDS),build-$(build)/kcf_vot)
8
9 CMAKE_OPTS += -G Ninja
10
11 ## Useful setting - uncomment and modify as needed
12 # CMAKE_OPTS += -DOpenCV_DIR=~/opt/opencv-2.4/share/OpenCV
13 # CMAKE_OPTS += -DCUDA_VERBOSE_BUILD=ON -DCUDA_NVCC_FLAGS="--verbose;--save-temps"
14 # export CC=gcc-5
15 # export CXX=g++-5
16 # export CUDA_BIN_PATH=/usr/local/cuda-9.0
17
18 CMAKE_OTPS_opencvfft-st      = -DFFT=OpenCV
19 CMAKE_OTPS_opencvfft-async   = -DFFT=OpenCV -DASYNC=ON
20 CMAKE_OTPS_opencvfft-openmp  = -DFFT=OpenCV -DOPENMP=ON
21 CMAKE_OTPS_fftw              = -DFFT=fftw
22 CMAKE_OTPS_fftw-openmp       = -DFFT=fftw -DOPENMP=ON
23 CMAKE_OTPS_fftw-async        = -DFFT=fftw -DASYNC=ON
24 CMAKE_OTPS_fftw-big          = -DFFT=fftw -DBIG_BATCH=ON
25 CMAKE_OTPS_fftw-big-openmp   = -DFFT=fftw -DBIG_BATCH=ON -DOPENMP=ON
26 CMAKE_OTPS_cufftw            = -DFFT=cuFFTW
27 CMAKE_OTPS_cufftw-big        = -DFFT=cuFFTW -DBIG_BATCH=ON
28 CMAKE_OTPS_cufftw-big-openmp = -DFFT=cuFFTW -DBIG_BATCH=ON -DOPENMP=ON
29 CMAKE_OTPS_cufft             = -DFFT=cuFFT
30 CMAKE_OTPS_cufft-openmp      = -DFFT=cuFFT -DOPENMP=ON
31 CMAKE_OTPS_cufft-big         = -DFFT=cuFFT -DBIG_BATCH=ON
32 CMAKE_OTPS_cufft-big-openmp  = -DFFT=cuFFT -DBIG_BATCH=ON -DOPENMP=ON
33
34 .SECONDARY: $(BUILDS:%=build-%/build.ninja)
35
36 build-%/build.ninja:
37         @echo '############################################################'
38         mkdir -p $(@D)
39         cd $(@D) && cmake $(CMAKE_OPTS) $(CMAKE_OTPS_$*) ..
40
41 .PHONY: FORCE
42 build-%/kcf_vot: build-%/build.ninja $(shell git ls-files)
43         @echo '############################################################'
44         cmake --build $(@D)
45
46 $(BUILDS): %: build-%/kcf_vot
47
48 clean:
49         rm -rf $(BUILDS:%=build-%)
50
51 ##########################
52 ### Tests
53 ##########################
54
55 print-test-results = grep ^Average $(1)|sed -E -e 's|build-(.*)/kcf_vot-(.*).log:|\2;\1;|'|sort|column -t -s';'
56
57 test: $(BUILDS:%=test-%)
58         @echo; echo "Summary test results:"
59         @$(call print-test-results,$(foreach build,$(BUILDS),\
60                                    $(foreach seq,$(TESTSEQ),\
61                                    $(foreach f,$(TESTFLAGS),build-$(build)/kcf_vot-$(seq)-$(f).log))))
62
63 $(BUILDS:%=test-%): test-%:
64         @$(call print-test-results,$(foreach seq,$(TESTSEQ),\
65                                    $(foreach f,$(TESTFLAGS),build-$*/kcf_vot-$(seq)-$(f).log)))
66
67 # Usage: testcase <build> <seq>
68 define testcase
69 test-$(1): test-$(1)-$(2)
70 test-$(1)-$(2): $(foreach f,$(TESTFLAGS),build-$(1)/kcf_vot-$(2)-$(f).log)
71 $(foreach f,$(TESTFLAGS),build-$(1)/kcf_vot-$(2)-$(f).log): build-$(1)/kcf_vot $$(filter-out %/output.txt,$$(wildcard vot2016/$(2)/*)) | vot2016/$(2)
72         $$< $$(if $$(@:%fit128.log=),,--fit=128) vot2016/$(2) > $$@
73         $(if $(TRAVIS),,cat $$@)
74 endef
75
76 $(foreach build,$(BUILDS),$(foreach seq,$(TESTSEQ),$(eval $(call testcase,$(build),$(seq)))))
77
78 vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip
79         unzip -d vot2016 -q $^
80         for i in $$(ls -d vot2016/*/); do ( echo Creating $${i}images.txt; cd $$i; ls *.jpg > images.txt ); done
81
82 .INTERMEDIATE: vot2016.zip
83 .SECONDARY:    vot2016.zip
84 vot2016.zip:
85         wget http://data.votchallenge.net/vot2016/vot2016.zip
86
87 ###################
88 # Ninja generator #
89 ###################
90
91 # Building all $(BUILDS) with make is slow, even when run with in
92 # parallel (make -j). The target below generates build.ninja file that
93 # compiles all variants in the same ways as this makefile, but faster.
94 # The down side is that the build needs about 10 GB of memory.
95
96 ninja: build.ninja
97         ninja
98
99 # Ninja generator - to have faster parallel builds
100 .PHONY: build.ninja
101 build.ninja:
102         $(file >$@,$(ninja-rule))
103         $(foreach build,$(BUILDS),$(file >>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build)))))
104
105 define ninja-rule
106 rule cmake
107   command = cd $$$$(dirname $$out) && cmake $(CMAKE_OPTS) $$opts ..
108   description = CMake $$out
109 rule ninja
110   # Absolute path in -C allows Emacs to properly jump to error message locations
111   command = ninja -C `realpath $$$$(dirname $$out)`
112   description = Ninja $$out
113 endef
114
115 define ninja-build
116 build build-$(1)/build.ninja: cmake
117   opts = $(2)
118 build build-$(1)/kcf_vot: ninja build-$(1)/build.ninja build.ninja
119 endef