master v1.1.0
Avril 4 years ago
parent ecd5f3181c
commit 3f76926dd7
Signed by: flanchan
GPG Key ID: 284488987C31F630

1
.gitignore vendored

@ -2,4 +2,5 @@
test* test*
obj/ obj/
hexview hexview
hexview-pgo
profile/ profile/

@ -11,7 +11,18 @@ LDFLAGS+= -lfmt
PROJ = hexview PROJ = hexview
OBJ = $(addprefix obj/,$(SRC:.cpp=.o)) OBJ = $(addprefix obj/,$(SRC:.cpp=.o))
PROF_OBJ = $(addprefix profile/,$(SRC:.cpp=.o))
### PGO target specific ###
# Number of times to run profiling
PGO_ITERATIONS = 512
# Size in kb of training files
PGO_DATASET_SIZE = $$(( 1024 * 4 ))
PGO_OBJ = $(addprefix profile/,$(SRC:.cpp=.o))
PROF_FLAGS = -fprofile-generate
###
.PHONY: all .PHONY: all
all: dirs $(PROJ) all: dirs $(PROJ)
@ -24,24 +35,38 @@ obj/%.o: %.cpp
$(CXX) -c $< $(_HX_FEAT) $(CXXFLAGS) -o $@ $(LDFLAGS) $(CXX) -c $< $(_HX_FEAT) $(CXXFLAGS) -o $@ $(LDFLAGS)
profile/%.o: %.cpp profile/%.o: %.cpp
$(CXX) -c $< $(_HX_FEAT) $(CXXFLAGS) -fprofile-generate -o $@ $(LDFLAGS) $(CXX) -c $< $(_HX_FEAT) $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
$(PROJ): $(OBJ) $(PROJ): $(OBJ)
$(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS) $(CXX) $^ $(CXXFLAGS) -o $@ $(LDFLAGS)
strip $@ strip $@
pgo-generate: $(PROF_OBJ) pgo-generate: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) -fprofile-generate -o $@ $(LDFLAGS) $(CXX) $^ $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
pgo-profile: pgo-generate pgo-profile: dirs pgo-generate
for i in {1..32}; do \ for i in {1..$(PGO_ITERATIONS)}; do \
dd if=/dev/urandom of=./pgo-test bs=1024 count=1024 \ dd if=/dev/urandom of=./pgo-test bs=1024 count=$(PGO_DATASET_SIZE) >> /dev/null 2>&1; \
./pgo-generate ./pgo-test printf "\rIteration $$i / $(PGO_ITERATIONS)"; \
./pgo-generate ./pgo-test > ./pgo-output; \
done done
@echo ""
rm ./pgo-test rm ./pgo-test
rm ./pgo-output
rm pgo-generate
pgo-use: PROF_FLAGS = -fprofile-use -lgcov
pgo-use: $(PGO_OBJ)
$(CXX) $^ $(CXXFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)
$(PROJ)-pgo: dirs pgo-profile pgo-use
mv pgo-use $@
strip $@
clean: clean:
rm -f $(PROJ) rm -f $(PROJ)
rm -f $(PROJ)-pgo
rm -rf obj rm -rf obj
rm -rf profile rm -rf profile
rm -f pgo-generate rm -f pgo-{test,output,generate}

Loading…
Cancel
Save