added pgo target

progress
Avril 4 years ago
parent 6b2b9a4a9d
commit a89f6ed47e
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -39,6 +39,16 @@ OBJ_C = $(addprefix obj/c/,$(SRC_C:.c=.o))
OBJ_CXX = $(addprefix obj/cxx/,$(SRC_CXX:.cpp=.o))
OBJ = $(OBJ_C) $(OBJ_CXX)
PGO_OBJ_C = $(addprefix obj/pgo/c/,$(SRC_C:.c=.o))
PGO_OBJ_CXX = $(addprefix obj/pgo/cxx/,$(SRC_CXX:.cpp=.o))
PGO_OBJ = $(PGO_OBJ_C) $(PGO_OBJ_CXX)
PGO_ITERATIONS=5
PGO_SET_LOC?=/tmp/$(PROJECT)-pgo
PGO_FLAGS = -fprofile-generate
PGO_LDFLAGS=
# Phonies
.PHONY: release
@ -47,14 +57,16 @@ release: | dirs $(PROJECT)-release
.PHONY: debug
debug: | dirs $(PROJECT)-debug
.PHONY: pgo
pgo: | dirs $(PROJECT)-pgo
.PHONY: test
test: test-all
# Targets
dirs:
@mkdir -p obj/c{,xx}/src
@mkdir -p obj/cxx/src/rng
@mkdir -p obj/{pgo/,}c{,xx}/src{,/rng}
obj/c/%.o: %.c
$(CC) -c $< $(CFLAGS) -o $@ $(LDFLAGS)
@ -62,6 +74,12 @@ obj/c/%.o: %.c
obj/cxx/%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@ $(LDFLAGS)
obj/pgo/c/%.o: %.c
$(CC) -c $< $(CFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
obj/pgo/cxx/%.o: %.cpp
$(CXX) -c $< $(CXXFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
$(PROJECT)-release: CFLAGS+= $(RELEASE_CFLAGS)
$(PROJECT)-release: CXXFLAGS += $(RELEASE_CXXFLAGS)
@ -76,11 +94,49 @@ $(PROJECT)-debug: LDFLAGS += $(DEBUG_LDFLAGS)
$(PROJECT)-debug: $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
pgo-generate: CFLAGS+= $(RELEASE_CFLAGS)
pgo-generate: CXXFLAGS += $(RELEASE_CXXFLAGS)
pgo-generate: LDFLAGS += $(RELEASE_LDFLAGS)
pgo-generate: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
pgo-reset:
find ./obj/pgo -name \*.gcda -exec rm {} +
pgo-profile: | pgo-reset pgo-generate
mkdir -p $(PGO_SET_LOC)
for i in {1..$(PGO_ITERATIONS)}; do \
dd if=/dev/urandom of=$(PGO_SET_LOC)/small bs=1024 count=1 >> /dev/null 2>&1; \
printf "Iteration $$i / $(PGO_ITERATIONS)\r"; \
./pgo-generate -s $(PGO_SET_LOC)/small >>/dev/null; \
./pgo-generate -u $(PGO_SET_LOC)/small >>/dev/null; \
./pgo-generate -h >> /dev/null; \
FCNT=1 ./test.sh ./pgo-generate >>/dev/null; \
FCNT=2 ./test.sh ./pgo-generate >>/dev/null; \
FCNT=3 ./test.sh ./pgo-generate >>/dev/null; \
FCNT=4 ./test.sh ./pgo-generate >>/dev/null; \
done
rm -rf $(PGO_SET_LOC)
rm pgo-generate
pgo-use: PGO_FLAGS = -fprofile-use
pgo-use: PGO_LDFLAGS = -lgcov -fprofile-use
pgo-use: CFLAGS+= $(RELEASE_CFLAGS)
pgo-use: CXXFLAGS += $(RELEASE_CXXFLAGS)
pgo-use: LDFLAGS += $(RELEASE_LDFLAGS)
pgo-use: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PGO_FLAGS) -o $@ $(LDFLAGS) $(PGO_LDFLAGS)
$(PROJECT)-pgo: | pgo-profile
find ./obj/pgo -name \*.o -exec rm {} +
$(MAKE) pgo-use
mv pgo-use $@
clean-rebuild:
rm -rf obj
clean: clean-rebuild
rm -f $(PROJECT)-{release,debug}
rm -f $(PROJECT)-{release,debug,pgo}
test-all:
@./test.sh ./$(PROJECT)-*

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Loading…
Cancel
Save