From 96236aa8bec0629631dba0c4b560b8e7646d172a Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 23 Nov 2020 13:07:25 +0000 Subject: [PATCH] working PGO target --- .gitignore | 1 + Makefile | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index fd9057f..c0740a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ obj/ +prof/ fcmp-* test/ perf.* diff --git a/Makefile b/Makefile index b8fdd62..686fa56 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ INCLUDE=include PROJECT=fcmp -OPT_FLAGS+= -fgraphite +OPT_FLAGS+= -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 FEAT_CFLAGS?= -D_RUN_THREADED=0 FEAT_LDFLAGS?= -lpthread @@ -19,14 +19,13 @@ LDFLAGS+= $(FEAT_LDFLAGS) # PGO specific vars -PROF_ITERATIONS=10 +PROF_ITERATIONS=50 PROF_LARGE_BOUND= $$(( 1024 * 1024 * 10 )) PROF_SMALL_BOUND= $$(( 1024 * 10 )) PROF_LOCATION?=/tmp/fcmp-pgo PROF_FLAGS = -fprofile-generate - OBJ = $(addprefix obj/,$(SRC:.c=.o)) PGO_OBJ = $(addprefix prof/,$(SRC:.c=.o)) @@ -67,7 +66,7 @@ pgo-generate: $(PGO_OBJ) pgo-reset: find ./prof -name \*.gcda -exec rm {} + -pgo-profile: pgo-reset pgo-generate +pgo-profile: | pgo-reset pgo-generate #./profile/gen $(PROF_LARGE_BOUND) "$(PROF_LOCATION)/large" #./profile/gen $(PROF_SMALL_BOUND) "$(PROF_LOCATION)/small" for i in {1..$(PROF_ITERATIONS)}; do \ @@ -76,10 +75,11 @@ pgo-profile: pgo-reset pgo-generate printf "Iteration $$i of $(PROF_ITERATIONS)\r"; \ ./profile/gen $(PROF_LARGE_BOUND) "$(PROF_LOCATION)/large" >> /dev/null; \ ./profile/gen $(PROF_SMALL_BOUND) "$(PROF_LOCATION)/small" >> /dev/null; \ - ./pgo-generate $(PROF_LOCATION)/large/matching/* > $(PROF_LOCATION)/stdout; \ - ./pgo-generate $(PROF_LOCATION)/large/unmatching/* > $(PROF_LOCATION)/stdout; \ - ./pgo-generate $(PROF_LOCATION)/small/matching/* > $(PROF_LOCATION)/stdout; \ - ./pgo-generate $(PROF_LOCATION)/small/unmatching/* > $(PROF_LOCATION)/stdout; \ + ./pgo-generate $(PROF_LOCATION)/large/matching/* & > $(PROF_LOCATION)/stdout; \ + ./pgo-generate $(PROF_LOCATION)/large/unmatching/* & > $(PROF_LOCATION)/stdout; \ + ./pgo-generate $(PROF_LOCATION)/small/matching/* & > $(PROF_LOCATION)/stdout; \ + ./pgo-generate $(PROF_LOCATION)/small/unmatching/* & > $(PROF_LOCATION)/stdout; \ + wait; \ rm -rf $(PROF_LOCATION)/{large,small}; \ done @echo "" @@ -88,7 +88,7 @@ pgo-profile: pgo-reset pgo-generate pgo-use: CFLAGS := $(RELEASE_CFLAGS) $(CFLAGS) pgo-use: LDFLAGS := $(RELEASE_LDFLAGS) $(LDFLAGS) -pgo-use: PROF_FLAGS = -fprofile-use +pgo-use: PROF_FLAGS = -fprofile-use -fprofile-correction pgo-use: $(PGO_OBJ) $(CC) $^ $(CFLAGS) $(PROF_FLAGS) -o $@ $(LDFLAGS) $(PROF_FLAGS)