PGO (Profile Guided Optimization)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

PGO (Profile Guided Optimization)

Jan Wielemaker

I was wondering whether there is a module or skeleton floating around to
deal with Profile Guided Optimization using a cmake build. If this rings
a bell you probably know the sequence (assuming GCC):

   - compile using -fprofile-generate
   - run a benchmark suite, this generates .gcda files for each object,
     which may be placed in a different directory.
   - recompile using -fprofile-use

Targetting Ninja, I now use a shell-script that performs

   - ninja -t clean my-target
   - ninja my-target
   - <run benchmark>
   - ninja -t clean my-target
   - ninja my-target

Where my-target is the time critical sub-project and
PROFILE_GUIDED_OPTIMIZATION is picked up by cmake and sets the compile
and link flags for the affected targets.

This isn't nice. I guess that ideally I'd have a separate build
subdirectory that always uses -fprofile-generate and the main build dir
using -fprofile-use. Does that make sense? Is there an

        Thanks --- Jan

Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: