Makefiles : checking dependencies beforehand && added help text
This commit is contained in:
parent
ff8142e678
commit
226df0882c
127
cpp/Makefile
127
cpp/Makefile
@ -1,80 +1,135 @@
|
||||
CC := nvcc -m64 -std=c++17 -ccbin g++-12 -Xcompiler -m64,-std=c++17
|
||||
CC := nvcc -m64 -t=0 -std=c++17 -Xcompiler -m64,-std=c++17
|
||||
OBJ_DIR := bin
|
||||
$(shell mkdir -p $(OBJ_DIR))
|
||||
MODELS_DIR := models
|
||||
OUT_DIR := out
|
||||
SRC_DIR := .
|
||||
#CFLAGS := -O0 -Werror=all-warnings -g -G
|
||||
#CFLAGS := $(CFLAGS) -pg
|
||||
#CFLAGS := $(CFLAGS) -Xptxas=-w
|
||||
#CFLAGS := $(CFLAGS) -Xcompiler -Wall,-O0,-g,-Werror,-Werror=implicit-fallthrough=0,-Wextra,-rdynamic
|
||||
CFLAGS := -O4 -Xcompiler -O4
|
||||
DATA_PATH := ../data
|
||||
#CFLAGS := -O0 -g -G -Xptxas=-w -Xcompiler -O0,-rdynamic,-g
|
||||
#CFLAGS := -O0 -g -G -pg -Xptxas=-w -Xcompiler -O0,-rdynamic,-g
|
||||
CFLAGS := -dlto -O2 -Xcompiler -O2
|
||||
#CFLAGS := -dlto -O2 -g -Xcompiler -O2,-g,-ggdb
|
||||
CFLAGS := $(CFLAGS) -MMD -MP -Werror=all-warnings -Xcompiler -Wall,-Werror,-Werror=implicit-fallthrough=0,-Wextra
|
||||
EXEC := $(OBJ_DIR)/ViolaJones
|
||||
SRC := $(shell find $(SRC_DIR) -name "*.cpp" -o -name "*.cu" )
|
||||
DATA := $(DATA_PATH)/X_train.bin $(DATA_PATH)/X_test.bin $(DATA_PATH)/y_train.bin $(DATA_PATH)/y_test.bin
|
||||
SRC := $(shell find $(SRC_DIR) -name '*.cpp' -o -name '*.cu' )
|
||||
OBJ_EXT := o
|
||||
ifeq ($(OS), Windows_NT)
|
||||
EXEC:=$(EXEC).exe
|
||||
OBJ_EXT:=obj
|
||||
EXEC := $(EXEC).exe
|
||||
OBJ_EXT := obj
|
||||
endif
|
||||
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.$(OBJ_EXT))
|
||||
OBJ := $(OBJ:$(SRC_DIR)/%.cu=$(OBJ_DIR)/%.$(OBJ_EXT))
|
||||
|
||||
.PHONY: all start reset clean mrproper debug check
|
||||
.PHONY: all
|
||||
all: $(EXEC)
|
||||
|
||||
all: $(EXEC) $(DATA)
|
||||
$(OBJ_DIR):
|
||||
@mkdir -v $@
|
||||
|
||||
# Compiling host code
|
||||
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.cpp
|
||||
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.cpp | $(OBJ_DIR) check-nvcc-works
|
||||
@echo Compiling $<
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# Compiling gpu code
|
||||
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.cu
|
||||
$(OBJ_DIR)/%.$(OBJ_EXT): $(SRC_DIR)/%.cu | $(OBJ_DIR) check-nvcc-works
|
||||
@echo Compiling $<
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(EXEC): $(OBJ)
|
||||
$(EXEC): $(OBJ) | check-nvcc-works
|
||||
@echo Linking objects files to $@
|
||||
@$(CC) $(CFLAGS) $^ -o $@
|
||||
|
||||
$(DATA):
|
||||
@echo 'Missing $(DATA) files, use downloader first' && exit 1
|
||||
|
||||
.PHONY: start
|
||||
start: $(EXEC) $(DATA)
|
||||
@./$(EXEC)
|
||||
|
||||
profile: start
|
||||
@gprof $(EXEC) gmon.out | gprof2dot | dot -Tpng -o output.png
|
||||
#@gprof $(EXEC) gmon.out > analysis.txt
|
||||
|
||||
.PHONY: debug
|
||||
debug: $(EXEC) $(DATA)
|
||||
#@cuda-gdb -q $(EXEC)
|
||||
@gdb -q --tui $(EXEC)
|
||||
|
||||
check: $(EXEC) $(DATA)
|
||||
.PHONY: profile
|
||||
profile: start | check-gprof-works check-gprof2dot-works check-dot-works
|
||||
@gprof $(EXEC) gmon.out | gprof2dot | dot -T png -o output.png
|
||||
|
||||
.PHONY: check
|
||||
check: $(EXEC) $(DATA) | check-valgrind-works
|
||||
@valgrind -q -s --leak-check=full --show-leak-kinds=all $(EXEC)
|
||||
|
||||
cudacheck: $(EXEC) $(DATA)
|
||||
@cuda-memcheck --destroy-on-device-error kernel --tool memcheck --leak-check full --report-api-errors all $(EXEC)
|
||||
#@cuda-memcheck --destroy-on-device-error kernel --tool racecheck --racecheck-report all $(EXEC)
|
||||
#@cuda-memcheck --destroy-on-device-error kernel --tool initcheck --track-unused-memory yes $(EXEC)
|
||||
#@cuda-memcheck --destroy-on-device-error kernel --tool synccheck $(EXEC)
|
||||
#@compute-sanitizer --destroy-on-device-error kernel --tool memcheck --leak-check full --report-api-errors all --track-stream-ordered-races all $(EXEC)
|
||||
#@compute-sanitizer --destroy-on-device-error kernel --tool racecheck --racecheck-detect-level info --racecheck-report all $(EXEC)
|
||||
#@compute-sanitizer --destroy-on-device-error kernel --tool initcheck --track-unused-memory yes $(EXEC)
|
||||
#@compute-sanitizer --destroy-on-device-error kernel --tool synccheck $(EXEC)
|
||||
.PHONY: cudacheck
|
||||
cudacheck: $(EXEC) $(DATA) | check-computer-sanitizer-works
|
||||
@compute-sanitizer --destroy-on-device-error kernel --tool memcheck --leak-check full --report-api-errors all --track-stream-ordered-races all --target-processes all $(EXEC)
|
||||
#@compute-sanitizer --destroy-on-device-error kernel --tool racecheck --racecheck-detect-level info --racecheck-report all $(EXEC)
|
||||
#@compute-sanitizer --destroy-on-device-error kernel --tool initcheck --track-unused-memory yes $(EXEC)
|
||||
#@compute-sanitizer --destroy-on-device-error kernel --tool synccheck $(EXEC)
|
||||
|
||||
r2: $(EXEC) $(DATA)
|
||||
@r2 $(EXEC)
|
||||
.PHONY: log
|
||||
log: $(DATA) reset
|
||||
@echo 'Building GPU'
|
||||
@sed -i 's/GPU_BOOSTED false/GPU_BOOSTED true/' config.hpp
|
||||
@make -s -j "$(shell nproc)"
|
||||
@echo 'Logging GPU'
|
||||
@make -s start > log_gpu
|
||||
@echo 'Building CPU'
|
||||
@sed -i 's/GPU_BOOSTED true/GPU_BOOSTED false/' config.hpp
|
||||
@make -s -j "$(shell nproc)"
|
||||
@echo 'Logging CPU'
|
||||
@make -s start > log_cpu
|
||||
@sed -i 's/GPU_BOOSTED false/GPU_BOOSTED true/' config.hpp
|
||||
@echo 'Cleaning up'
|
||||
@make -s reset
|
||||
|
||||
.PHONY: reset
|
||||
reset:
|
||||
@echo Deleting generated states and models
|
||||
@rm -rf $(OUT_DIR)/* $(MODELS_DIR)/* | true
|
||||
@echo 'Deleting generated states and models'
|
||||
@rm -frv $(OUT_DIR)/* $(MODELS_DIR)/*
|
||||
#@ln -sv /mnt/pierre_stuffs/ViolaJones/cpp/models .
|
||||
#@ln -sv /mnt/pierre_stuffs/ViolaJones/cpp/out .
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm $(EXEC)
|
||||
@rm -fv $(EXEC) log_gpu log_cpu
|
||||
|
||||
mrproper:
|
||||
@rm -r $(OBJ_DIR)
|
||||
.PHONY: mrproper
|
||||
mrproper: clean
|
||||
@rm -rfv $(OBJ_DIR) gmon.out
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@echo "\tall: alias for start, (default target)"
|
||||
@echo "\tstart: Start the ViolaJones algorithm, require data beforehand downloaded by the downloader."
|
||||
@echo "\tdebug: Debug the ViolaJones algorithm, require data beforehand downloaded by the downloader."
|
||||
@echo "\tprofile: Profile the ViolaJones algorithm functions timestamps, require data beforehand downloaded by the downloader."
|
||||
@echo "\treset: Will delete any saved models and processed data made by ViolaJones."
|
||||
@echo "\tmrproper: Will remove cpp binary files. Will execute reset target beforehand."
|
||||
|
||||
.PHONY: check-nvcc-works
|
||||
check-nvcc-works:
|
||||
@nvcc --version >/dev/null 2>&1 || (echo 'Please install NVIDIA Cuda compiler.' && exit 1)
|
||||
|
||||
.PHONY: check-gprof-works
|
||||
check-gprof-works:
|
||||
@gprof --version >/dev/null 2>&1 || (echo 'Please install GNU gprof.' && exit 1)
|
||||
|
||||
.PHONY: check-gprof2dot-works
|
||||
check-gprof2dot-works:
|
||||
@gprof2dot --help >/dev/null 2>&1 || (echo 'Please install gprof2dot.' && exit 1)
|
||||
|
||||
.PHONY: check-dot-works
|
||||
check-dot-works:
|
||||
@dot --version >/dev/null 2>&1 || (echo 'Please install dot from graphviz.' && exit 1)
|
||||
|
||||
.PHONY: check-valgrind-works
|
||||
check-valgrind-works:
|
||||
@valgrind --version >/dev/null 2>&1 || (echo 'Please install valgrind.' && exit 1)
|
||||
|
||||
.PHONY: check-computer-sanitizer-works
|
||||
check-computer-sanitizer-works:
|
||||
@computer-sanitizer --version >/dev/null 2>&1 || (echo 'Please install Compute Sanitizer from Cuda toolkit.' && exit 1)
|
||||
|
||||
-include $(OBJ:.o=.d)
|
||||
|
@ -1,35 +1,85 @@
|
||||
MODELS_DIR := models
|
||||
OUT_DIR := out
|
||||
DATA_PATH := ../data
|
||||
DATA := $(DATA_PATH)/X_train.bin $(DATA_PATH)/X_test.bin $(DATA_PATH)/y_train.bin $(DATA_PATH)/y_test.bin
|
||||
|
||||
.PHONY: all start reset
|
||||
|
||||
all: ${DATA}
|
||||
.PHONY: all
|
||||
all: venv
|
||||
|
||||
$(DATA):
|
||||
@echo 'Missing $(DATA) files, use downloader first' && exit 1
|
||||
|
||||
.PHONY: venv
|
||||
venv:
|
||||
@bash -c 'source activate.sh'
|
||||
@sh -c '. ./activate.sh'
|
||||
|
||||
start: ${DATA} venv
|
||||
@bash -c 'source activate.sh && python projet.py'
|
||||
.PHONY: start
|
||||
start: $(DATA) | venv check-python-works
|
||||
@sh -c '. ./activate.sh && python projet.py'
|
||||
|
||||
reset:
|
||||
@echo Deleting generated states and models
|
||||
@rm -rf out/* models/* | true
|
||||
|
||||
debug:
|
||||
.PHONY: debug
|
||||
debug: $(DATA) | venv check-python-works check-pudb-works
|
||||
@bash -c 'source activate.sh && pudb projet.py'
|
||||
|
||||
profile:
|
||||
@bash -c 'source activate.sh && python -m cProfile -o prof.out projet.py && gprof2dot -f pstats prof.out | dot -Tpng -o output.png'
|
||||
.PHONY: profile
|
||||
profile: $(DATA) | venv check-python-works check-gprof2dot-works check-dot-works
|
||||
@bash -c 'source activate.sh && python -m cProfile -o prof.out projet.py && gprof2dot -f pstats prof.out | dot -T png -o output.png'
|
||||
|
||||
mrproper: reset
|
||||
@rm -r __pycache__ venv
|
||||
.PHONY: log
|
||||
log: $(DATA) reset | venv
|
||||
@sed -i 's/GPU_BOOSTED: Final = False/GPU_BOOSTED: Final = True/;s/COMPILE_WITH_C: Final = False/COMPILE_WITH_C: Final = True/' config.py
|
||||
@echo 'Logging GPU'
|
||||
@make -s start > log_gpu
|
||||
@sed -i 's/GPU_BOOSTED: Final = True/GPU_BOOSTED: Final = False/' config.py
|
||||
@echo 'Logging CPU'
|
||||
@make -s start > log_cpu
|
||||
@sed -i 's/GPU_BOOSTED: Final = False/GPU_BOOSTED: Final = True/;s/COMPILE_WITH_C: Final = True/COMPILE_WITH_C: Final = False/' config.py
|
||||
@echo 'Logging PGPU'
|
||||
@make -s start > log_pgpu
|
||||
@sed -i 's/GPU_BOOSTED: Final = True/GPU_BOOSTED: Final = False/' config.py
|
||||
@echo 'Logging PY'
|
||||
@make -s start > log_py
|
||||
@echo 'Cleaning up'
|
||||
@make -s reset
|
||||
|
||||
test:
|
||||
@bash -c 'source activate.sh && ls out | sed s/.pkl// | xargs -n1 python test_diff.py out'
|
||||
@bash -c 'source activate.sh && ls models | sed s/.pkl// | xargs -n1 python test_diff.py models'
|
||||
.PHONY: reset
|
||||
reset:
|
||||
@echo 'Deleting generated states and models'
|
||||
@rm -frv $(OUT_DIR)/* $(MODELS_DIR)/*
|
||||
#@ln -sv /mnt/pierre_stuffs/ViolaJones/python/models .
|
||||
#@ln -sv /mnt/pierre_stuffs/ViolaJones/python/out .
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -fv log_gpu log_cpu log_gpu log_py
|
||||
|
||||
.PHONY: mrproper
|
||||
mrproper: clean
|
||||
@rm -rfv __pycache__ venv
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "all start reset mrproper help"
|
||||
@echo "Available targets:"
|
||||
@echo "\tall: alias for start, (default target)"
|
||||
@echo "\tvenv: Create python virtual environnement."
|
||||
@echo "\tstart: Start the ViolaJones algorithm, require data beforehand downloaded by the downloader."
|
||||
@echo "\tdebug: Debug the ViolaJones algorithm, require data beforehand downloaded by the downloader."
|
||||
@echo "\tprofile: Profile the ViolaJones algorithm functions timestamps, require data beforehand downloaded by the downloader."
|
||||
@echo "\treset: Will delete any saved models and processed data made by ViolaJones."
|
||||
@echo "\tmrproper: Will remove cpp binary files. Will execute reset target beforehand."
|
||||
|
||||
.PHONY: check-python-works
|
||||
check-python-works:
|
||||
@python --version >/dev/null 2>&1 || (echo 'Please install Python.' && exit 1)
|
||||
|
||||
.PHONY: check-pudb-works
|
||||
check-pudb-works:
|
||||
@pudb --version >/dev/null 2>&1 || (echo 'Please install pudb.' && exit 1)
|
||||
|
||||
.PHONY: check-gprof2dot-works
|
||||
check-gprof2dot-works:
|
||||
@gprof2dot --help >/dev/null 2>&1 || (echo 'Please install gprof2dot.' && exit 1)
|
||||
|
||||
.PHONY: check-dot-works
|
||||
check-dot-works:
|
||||
@dot --version >/dev/null 2>&1 || (echo 'Please install dot from graphviz.' && exit 1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user