Hi.

As I spoke about the PGO with Honza and Richi, current 3-stage is not ideal for 
following
2 reasons:

1) stageprofile compiler is train just on libraries that are built during stage2
2) apart from that, as the compiler is also used to build the final compiler, 
profile
is being updated during the build. So the stage2 compiler is making different 
decisions.

Both problems can be resolved by adding another step in between current stage2 
and stage3
where we train stage2 compiler by building compiler with default options.

I'm going to do some measurements.

Ready for trunk?
Martin
>From 0a9c9a7f7d335e5e053ab37c5649371996e95325 Mon Sep 17 00:00:00 2001
From: marxin <mli...@suse.cz>
Date: Thu, 25 May 2017 11:35:29 +0200
Subject: [PATCH] Introduce 4-stages profiledbootstrap to get a better profile.

gcc/ChangeLog:

2017-05-25  Martin Liska  <mli...@suse.cz>

	* doc/install.texi: Document that PGO runs in 4 stages.

ChangeLog:

2017-05-25  Martin Liska  <mli...@suse.cz>

	* Makefile.def: Define 4 stages PGO bootstrap.
	* Makefile.tpl: Define FLAGS.
	* Makefile.in: Regenerate.
---
 Makefile.in          | 7 +++++--
 Makefile.tpl         | 7 +++++--
 gcc/doc/install.texi | 5 +++--
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index b824e0a0ca1..75e5a1a912b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -522,8 +522,11 @@ STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
 STAGEprofile_CFLAGS = $(STAGE2_CFLAGS) -fprofile-generate
 STAGEprofile_TFLAGS = $(STAGE2_TFLAGS)
 
-STAGEfeedback_CFLAGS = $(STAGE3_CFLAGS) -fprofile-use
-STAGEfeedback_TFLAGS = $(STAGE3_TFLAGS)
+STAGEtrain_CFLAGS = $(STAGE3_CFLAGS)
+STAGEtrain_TFLAGS = $(STAGE3_TFLAGS)
+
+STAGEfeedback_CFLAGS = $(STAGE4_CFLAGS) -fprofile-use
+STAGEfeedback_TFLAGS = $(STAGE4_TFLAGS)
 
 STAGEautoprofile_CFLAGS = $(STAGE2_CFLAGS) -g
 STAGEautoprofile_TFLAGS = $(STAGE2_TFLAGS)
diff --git a/Makefile.tpl b/Makefile.tpl
index d0fa07005be..5fcd7e358d9 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -455,8 +455,11 @@ STAGE1_CONFIGURE_FLAGS = --disable-intermodule $(STAGE1_CHECKING) \
 STAGEprofile_CFLAGS = $(STAGE2_CFLAGS) -fprofile-generate
 STAGEprofile_TFLAGS = $(STAGE2_TFLAGS)
 
-STAGEfeedback_CFLAGS = $(STAGE3_CFLAGS) -fprofile-use
-STAGEfeedback_TFLAGS = $(STAGE3_TFLAGS)
+STAGEtrain_CFLAGS = $(STAGE3_CFLAGS)
+STAGEtrain_TFLAGS = $(STAGE3_TFLAGS)
+
+STAGEfeedback_CFLAGS = $(STAGE4_CFLAGS) -fprofile-use
+STAGEfeedback_TFLAGS = $(STAGE4_TFLAGS)
 
 STAGEautoprofile_CFLAGS = $(STAGE2_CFLAGS) -g
 STAGEautoprofile_TFLAGS = $(STAGE2_TFLAGS)
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index b13fc1f6f42..386771872ba 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -2611,8 +2611,9 @@ bootstrap the compiler with profile feedback, use @code{make profiledbootstrap}.
 When @samp{make profiledbootstrap} is run, it will first build a @code{stage1}
 compiler.  This compiler is used to build a @code{stageprofile} compiler
 instrumented to collect execution counts of instruction and branch
-probabilities.  Then runtime libraries are compiled with profile collected.
-Finally a @code{stagefeedback} compiler is built using the information collected.
+probabilities.  Training run is done by building @code{stagetrain}
+compiler.  Finally a @code{stagefeedback} compiler is built
+using the information collected.
 
 Unlike standard bootstrap, several additional restrictions apply.  The
 compiler used to build @code{stage1} needs to support a 64-bit integral type.
-- 
2.12.2

Reply via email to