What information does GCC Profile Guided Optimization (PGO) collect and which optimizations use it?

∥☆過路亽.° 提交于 2019-11-27 18:58:36

-fprofile-generate enables -fprofile-arcs, -fprofile-values and -fvpt.

-fprofile-use enables -fbranch-probabilities, -fvpt, -funroll-loops, -fpeel-loops and -ftracer

Source: http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Optimize-Options.html#Optimize-Options

PS. Information about LTO also on that page.

"What Every Programmer Should Know About Memory" by Ulrich Drepper https://people.freebsd.org/~lstewart/articles/cpumemory.pdf http://www.akkadia.org/drepper/cpumemory.pdf

In section 7.4

  • compilation with --profile-generate generates .gcno file for each object file. (the same file that is used for gcov coverage reports)
  • then you must run a few tests, during runtime it records coverage data into .gcda files
  • recompile with --profile-use : it will gather the coverage data and infer if an branch is likely (__builtin_expect( .. , 1 ) or unlikely (__builtin_expect( .. , 0)

The result should run faster as it should be better at prefetching code into the processor instruction cache.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!