Added helper script for profile-guided optimization (PGO).

This commit is contained in:
LoRd_MuldeR 2020-10-29 18:12:21 +01:00
parent 6c26203c30
commit 37b6c40278
Signed by: mulder
GPG Key ID: 2B5913365F57E03F
2 changed files with 42 additions and 5 deletions

View File

@ -3,8 +3,9 @@
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
DEBUG ?= 0 DEBUG ?= 0
ASAN ?= 0
STATIC ?= 0 STATIC ?= 0
FPGO ?= 0
MARCH ?= native MARCH ?= native
MTUNE ?= native MTUNE ?= native
@ -25,12 +26,20 @@ ifeq ($(DEBUG),1)
CONFIG := _g CONFIG := _g
CFLAGS += -Og -g CFLAGS += -Og -g
LDFLGS := LDFLGS :=
else ifeq ($(ASAN),1)
CONFIG := _a
CFLAGS += -O1 -g -fsanitize=address -fno-omit-frame-pointer
LDFLGS :=
else else
CONFIG := CONFIG :=
CFLAGS += -O3 -DNDEBUG CFLAGS += -O3 -DNDEBUG
LDFLGS := -s LDFLGS := -s
endif endif
ifneq ($(FPGO),0)
CFLAGS += -fprofile-$(FPGO)
endif
MACHINE := $(shell $(CC) -dumpmachine) MACHINE := $(shell $(CC) -dumpmachine)
ifneq ($(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)),) ifneq ($(filter %mingw32 %-windows-gnu %-cygwin %-cygnus,$(MACHINE)),)
@ -101,5 +110,6 @@ $(SUBDIR_LIB)/obj/%$(CONFIG).o: $(SUBDIR_LIB)/src/%.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
clean: clean:
$(RM) $(SUBDIR_APP)/obj/*.o $(SUBDIR_APP)/lib/*.a $(SUBDIR_APP)/bin/*$(SUFFIX) $(RM) $(SUBDIR_APP)/obj/*.o $(SUBDIR_APP)/obj/*.gcda $(SUBDIR_APP)/lib/*.a $(SUBDIR_APP)/bin/*$(SUFFIX)
$(RM) $(SUBDIR_LIB)/obj/*.o $(SUBDIR_LIB)/lib/*.a $(SUBDIR_LIB)/bin/*$(SUFFIX) $(RM) $(SUBDIR_LIB)/obj/*.o $(SUBDIR_LIB)/obj/*.gcda $(SUBDIR_LIB)/lib/*.a $(SUBDIR_LIB)/bin/*$(SUFFIX)

27
mk-profiled.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
set -e
readonly PLATFORM="$(uname -a)"
unset SUFFIX
if [[ "${PLATFORM}" == MINGW* || "${PLATFORM}" == CYGWIN* ]]; then
SUFFIX=".exe"
fi
echo -e "\n------------------------------------------------------------------------------"
echo -e "Instrument"
echo -e "------------------------------------------------------------------------------\n"
make clean
make FPGO=generate -B "$@"
echo -e "\n------------------------------------------------------------------------------"
echo -e "Profiling"
echo -e "------------------------------------------------------------------------------\n"
./frontend/bin/slunkcrypt${SUFFIX} -t
echo -e "\n------------------------------------------------------------------------------"
echo -e "Re-compile"
echo -e "------------------------------------------------------------------------------\n"
make FPGO=use -B "$@"