[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT PATCH v2 1/2] build: Add PGO support



Profile-Guided Optimization is a method used by compilers to produce
optimal code by using application runtime data. PGO involves two
phases one that implies a compilation and a run that will generate
the profiling files for the application and one that implies a
compilation in which the compiler uses the profiling data to make a
better estimate of the program’s control flow and to produce an optimized
executable file.

Add the configuration for PGO phases in MENUCONFIG and the correspondent
flag for LDFLAGS.

Signed-off-by: Alice Suiu <alicesuiu17@xxxxxxxxx>
---
 Config.uk   | 26 ++++++++++++++++++++++++++
 Makefile.uk |  8 ++++++++
 2 files changed, 34 insertions(+)

diff --git a/Config.uk b/Config.uk
index 3235b91..a815b6b 100644
--- a/Config.uk
+++ b/Config.uk
@@ -86,6 +86,32 @@ config OPTIMIZE_LTO
                will increase overall building time but creates more efficient
                Unikraft binaries.
 
+config OPTIMIZE_PGO
+       bool "PGO - Profile-guided optimization"
+       default n
+       help
+               Enables GCC to do code optimizations through PGO.
+
+if OPTIMIZE_PGO
+       choice PGO_PHASES
+       prompt "PGO Options"
+       default OPTIMIZE_PGO_GENERATE
+       help
+               Enables GCC to do code optimizations through PGO.
+
+       config OPTIMIZE_PGO_GENERATE
+               bool "profile-generate"
+               help
+                       Enables GCC to generate data for code optimization 
through PGO.
+
+       config OPTIMIZE_PGO_USE
+               bool "profile-use"
+               help
+                       Enables GCC to do code optimizations using data 
generated from
+                       the profile-generated phase of PGO.
+       endchoice
+endif
+
 choice
        prompt "Debug information level"
        default DEBUG_SYMBOLS_LVL3
diff --git a/Makefile.uk b/Makefile.uk
index a78afc0..78d802c 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -36,6 +36,14 @@ COMPFLAGS-$(CONFIG_OPTIMIZE_LTO)          += -flto
 LIBLDFLAGS-$(CONFIG_OPTIMIZE_LTO)         += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y)
 LDFLAGS-$(CONFIG_OPTIMIZE_LTO)            += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y)
 
+# PGO - profile-generate phase - requires the -fprofile-generate flag
+# when compiling the application and linking all libraries in the system.
+LDFLAGS-$(CONFIG_OPTIMIZE_PGO_GENERATE)   += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-generate
+
+# PGO - profile-use phase - requires the -fprofile-use flag
+# when compiling the application and linking all libraries in the system.
+LDFLAGS-$(CONFIG_OPTIMIZE_PGO_USE)        += $(COMPFLAGS) $(COMPFLAGS-y) 
$(ARCHFLAGS) $(ARCHFLAGS-y) -fprofile-use
+
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0)     += -g0
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1)     += -g1
 DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL2)     += -g2
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.