1

Intel C(++) Compiler has very useful functions to help with profile guided optimisation.

_PGOPTI_Prof_Reset_All();
/* code */
_PGOPTI_Prof_Dump_All();

https://software.intel.com/en-us/node/512800

This is particularly useful for profiling shared libraries which one would use with ctypes in Python.

I've been trying to figure out if either Clang or GCC have similar functionality – apparently not.

2 Answers2

1

Profile guided optimization works differently in gcc and it is enabled with compiler switches. See this question for PGO with gcc.

PGO just recently arrived in clang and is only available starting at version 3.5. The clang user manual gives an overview of how to use it.

Community
  • 1
  • 1
pmr
  • 58,701
  • 10
  • 113
  • 156
0

It turns out that both have an internal and not properly documented function named __gcov_flush which does this. It is only explained in the source.

/* Called before fork or exec - write out profile information gathered so far and reset it to zero. This avoids duplication or loss of the profile information gathered so far. */

It's not quite as convenient as the Intel equivalent though and requires some gymnastics to make it work.