diff options
| author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
|---|---|---|
| committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
| commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
| tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/makefiles | |
| parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) | |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/common/makefiles')
| -rw-r--r-- | SD-VBS/common/makefiles/Makefile.common | 135 | ||||
| -rw-r--r-- | SD-VBS/common/makefiles/Makefile.include | 16 | ||||
| -rw-r--r-- | SD-VBS/common/makefiles/Makefile.recurse | 39 |
3 files changed, 190 insertions, 0 deletions
diff --git a/SD-VBS/common/makefiles/Makefile.common b/SD-VBS/common/makefiles/Makefile.common new file mode 100644 index 0000000..7fc8824 --- /dev/null +++ b/SD-VBS/common/makefiles/Makefile.common | |||
| @@ -0,0 +1,135 @@ | |||
| 1 | ################################# | ||
| 2 | # Author: Sravanthi Kota Venkata | ||
| 3 | ################################# | ||
| 4 | SHELL := /bin/bash | ||
| 5 | |||
| 6 | # Define MATLAB-PATH with the path to the MATLAB package | ||
| 7 | MATLAB_PATH = /pkg/bin/matlab | ||
| 8 | ifeq ($(filter matlab-run,$(MAKECMDGOALS)),matlab-run) | ||
| 9 | ifneq ($(wildcard $(MATLAB_PATH)),$(MATLAB_PATH)) | ||
| 10 | $(error Please set the appropriate MATLAB path in MATLAB_PATH variable) | ||
| 11 | endif | ||
| 12 | endif | ||
| 13 | |||
| 14 | ifeq ($(filter mcc-run,$(MAKECMDGOALS)),mcc-run) | ||
| 15 | ifneq ($(wildcard $(MATLAB_PATH)),$(MATLAB_PATH)) | ||
| 16 | $(error Please set the appropriate MATLAB path in MATLAB_PATH variable) | ||
| 17 | endif | ||
| 18 | endif | ||
| 19 | |||
| 20 | CC=gcc | ||
| 21 | override CFLAGS += -DGCC -D$(INPUT) -pthread -DCHECK | ||
| 22 | |||
| 23 | COMMON_DIR := $(TOP_DIR)/common/c | ||
| 24 | M_COMMON := $(TOP_DIR)/common/matlab | ||
| 25 | M_TOOLBOX=$(TOP_DIR)/common/toolbox | ||
| 26 | TIMING_DIR := $(TOP_DIR)/cycles/$(BMARK) | ||
| 27 | TIMES_DIR := $(TOP_DIR)/times/$(BMARK) | ||
| 28 | PRELOAD_TIMES_DIR := $(TOP_DIR)/preload-times/$(BMARK) | ||
| 29 | MTIMING_DIR := $(TOP_DIR)/cycles/$(BMARK) | ||
| 30 | BMARK_DIR := $(TOP_DIR)/benchmarks/$(BMARK) | ||
| 31 | TOOL_DIR := $(TOP_DIR)/tools | ||
| 32 | |||
| 33 | #The options set below and specific to each benchmark. Disparity takes 2 input images, whereas Tracking can take any >1 input images =. | ||
| 34 | |||
| 35 | # Variables exported from the benchmark specific Makefiles: | ||
| 36 | # BMARK | ||
| 37 | # INPUT - sqcif/qcif/cif | ||
| 38 | |||
| 39 | # Matlab source, data and result directory | ||
| 40 | |||
| 41 | M_DIR=$(BMARK_DIR)/src/matlab | ||
| 42 | M_DATA=$(BMARK_DIR)/data/$(INPUT) | ||
| 43 | M_RESULT=$(BMARK_DIR)/result | ||
| 44 | |||
| 45 | # C source, data and result directory | ||
| 46 | |||
| 47 | C_DIR=$(BMARK_DIR)/src/c | ||
| 48 | DATA_DIR=$(BMARK_DIR)/data/$(INPUT) | ||
| 49 | C_RESULT=$(M_RESULT) | ||
| 50 | |||
| 51 | # Source files for C and Common folders | ||
| 52 | |||
| 53 | C_SRC := $(wildcard $(C_DIR)/*.c) | ||
| 54 | COMMON_SRC := $(wildcard $(COMMON_DIR)/*.c) | ||
| 55 | |||
| 56 | # RULES | ||
| 57 | |||
| 58 | EXE = | ||
| 59 | INCLUDES = -I$(COMMON_DIR) -I$(C_DIR) | ||
| 60 | COMPILE_C = $(CC) $(CFLAGS) -lm -O2 $(INCLUDES) | ||
| 61 | #COMPILE_C = $(CC) $(CFLAGS) -DGENERATE_OUTPUT -lm -O2 $(INCLUDES) | ||
| 62 | COMPILE_G = $(CC) $(CFLAGS) -g -lm $(INCLUDES) | ||
| 63 | COMPILE_PG = $(COMPILE_G) -pg | ||
| 64 | |||
| 65 | preload-run: compile | ||
| 66 | @echo preloaded timing | ||
| 67 | @echo 3 | tee /proc/sys/vm/drop_caches | ||
| 68 | @find ./ -iname "*.bmp" -exec sh -c '$(TOOL_DIR)/preload {} &' \; | ||
| 69 | @find ./ -iname "*.txt" -exec sh -c '$(TOOL_DIR)/preload {} &' \; | ||
| 70 | mkdir -p $(PRELOAD_TIMES_DIR) | ||
| 71 | @echo -e "Data set\t\t- $(INPUT)" | ||
| 72 | (time ./$(BMARK)$(EXE) $(DATA_DIR)) |& tee $(PRELOAD_TIMES_DIR)/T_$(INPUT).txt | ||
| 73 | @kill -2 `pgrep preload` | ||
| 74 | |||
| 75 | time-run: compile | ||
| 76 | mkdir -p $(TIMES_DIR) | ||
| 77 | @echo -e "Data set\t\t- $(INPUT)" | ||
| 78 | @echo 3 | tee /proc/sys/vm/drop_caches | ||
| 79 | (time ./$(BMARK)$(EXE) $(DATA_DIR)) |& tee $(TIMES_DIR)/T_$(INPUT).txt | ||
| 80 | |||
| 81 | c-run: compile | ||
| 82 | @echo -e "Data set\t\t- $(INPUT)" | ||
| 83 | mkdir -p $(TIMING_DIR) | ||
| 84 | @./$(BMARK)$(EXE) $(DATA_DIR) $(C_RESULT) | tee $(TIMING_DIR)/C_$(INPUT).txt | ||
| 85 | |||
| 86 | run: compile | ||
| 87 | @echo -e "Data set\t\t- $(INPUT)" | ||
| 88 | @./$(BMARK)$(EXE) $(DATA_DIR) $(C_RESULT) | ||
| 89 | |||
| 90 | rt-run: compile | ||
| 91 | @echo -e "Data set\t\t- $(INPUT)" | ||
| 92 | @./$(BMARK)$(EXE) $(BMARK)-$(INPUT) 5 0 12345 1 | ||
| 93 | |||
| 94 | debug: | ||
| 95 | @echo Running Debug C Version of the benchmark | ||
| 96 | @$(COMPILE_G) $(COMMON_SRC) $(C_SRC) -o $(BMARK)$(EXE) | ||
| 97 | @valgrind --leak-check=full ./$(BMARK)$(EXE) $(DATA_DIR) $(C_RESULT) | ||
| 98 | #@gdb ./$(BMARK)$(EXE) $(DATA_DIR) $(C_RESULT) | ||
| 99 | |||
| 100 | profile: compile-prof | ||
| 101 | @echo -e "Data set\t\t- $(INPUT)" | ||
| 102 | @./$(BMARK)$(EXE) $(DATA_DIR) $(C_RESULT) | ||
| 103 | @gprof $(BMARK)$(EXE) | ||
| 104 | |||
| 105 | compile-preload: | ||
| 106 | @$(COMPILE_C) $(TOOL_DIR)\preload.c -o $(TOOL_DIR)\preload | ||
| 107 | |||
| 108 | compile: $(C_SRC) | ||
| 109 | @echo | ||
| 110 | @echo -e "Benchmark\t\t- $(BMARK)" | ||
| 111 | @$(COMPILE_C) $(COMMON_SRC) $(C_SRC) -lrt -lm -w -o $(BMARK)$(EXE) | ||
| 112 | |||
| 113 | compile-prof: $(C_SRC) | ||
| 114 | @echo | ||
| 115 | @echo -e "Benchmark\t\t- $(BMARK)" | ||
| 116 | @$(COMPILE_PG) $(COMMON_SRC) $(C_SRC) -o $(BMARK)$(EXE) | ||
| 117 | |||
| 118 | matlab-run: | ||
| 119 | @echo | ||
| 120 | @echo -e "Benchmark\t\t- $(BMARK)" | ||
| 121 | @echo -e "Data set\t\t- $(INPUT)" | ||
| 122 | @cd $(M_DIR); $(MATLAB_PATH) -glnx86 -nosplash -nodisplay -r "script_run_profile('$(M_DATA)', '$(M_RESULT)', '$(INPUT)', '$(M_COMMON)', '$(M_TOOLBOX)'); quit" | tee $(MTIMING_DIR)/Matlab_$(INPUT).txt | ||
| 123 | |||
| 124 | mcc-run: | ||
| 125 | @echo Generating a C standalone application | ||
| 126 | cd $(M_DIR); $(MATLAB_PATH) -nosplash -nodesktop -r "mcc -m -v script_run_profile -d $(M_RESULT); quit" | ||
| 127 | |||
| 128 | all: c-run matlab-run mcc-run | ||
| 129 | |||
| 130 | clean: | ||
| 131 | @-rm $(BMARK) | ||
| 132 | |||
| 133 | |||
| 134 | |||
| 135 | |||
diff --git a/SD-VBS/common/makefiles/Makefile.include b/SD-VBS/common/makefiles/Makefile.include new file mode 100644 index 0000000..f1000b9 --- /dev/null +++ b/SD-VBS/common/makefiles/Makefile.include | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | find-dir-with = $(shell /usr/bin/perl -e 'chomp($$_ = `pwd`); while ($$_ ne "" && ! -e "$$_/$(1)") { m:(.*)/[^/]+/??:; $$_ = $$1; } print;') | ||
| 2 | |||
| 3 | # define canonical directories in starsearch | ||
| 4 | ifndef TOP_DIR | ||
| 5 | export TOP_DIR := $(call find-dir-with,.SD-VBS) | ||
| 6 | endif | ||
| 7 | |||
| 8 | export MAKEFILE_COMMON_DIR=$(TOP_DIR)/common/makefiles | ||
| 9 | |||
| 10 | # backward compatibility | ||
| 11 | |||
| 12 | ifeq ($(TOP_DIR),) | ||
| 13 | $(error file .SD-VBS not found -- try running 'gmake setup' at the top of your source tree) | ||
| 14 | endif | ||
| 15 | |||
| 16 | |||
diff --git a/SD-VBS/common/makefiles/Makefile.recurse b/SD-VBS/common/makefiles/Makefile.recurse new file mode 100644 index 0000000..9a9d088 --- /dev/null +++ b/SD-VBS/common/makefiles/Makefile.recurse | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | # This file is included in the makefiles of the non-leaf nodes | ||
| 2 | # Thus the various targets in this file have to trickle down | ||
| 3 | # into the subdirectories | ||
| 4 | # List the subdirectories and call the target for each one of them | ||
| 5 | |||
| 6 | ################################################################ | ||
| 7 | # RECURSE | ||
| 8 | ################################################################ | ||
| 9 | # Listing the subdirectories | ||
| 10 | SUBDIRS = $(patsubst %/Makefile,%,$(wildcard */Makefile)) | ||
| 11 | |||
| 12 | RECURSE-DEPENDS = $(patsubst %,%.traverse,$(SUBDIRS)) | ||
| 13 | |||
| 14 | all: recurse | ||
| 15 | |||
| 16 | debug: recurse | ||
| 17 | |||
| 18 | clean: recurse | ||
| 19 | |||
| 20 | compile: recurse | ||
| 21 | |||
| 22 | c-run: recurse | ||
| 23 | |||
| 24 | matlab-run: recurse | ||
| 25 | |||
| 26 | mcc-run: recurse | ||
| 27 | |||
| 28 | recurse: $(RECURSE-DEPENDS) | ||
| 29 | |||
| 30 | time-run: recurse | ||
| 31 | |||
| 32 | preload-run: recurse | ||
| 33 | |||
| 34 | run: recurse | ||
| 35 | |||
| 36 | # MAKECMDGOALS contains the gmake target specified on the command line | ||
| 37 | # it is defined automatically by gmake | ||
| 38 | %.traverse: | ||
