如何在 g++ 中使用配置文件引导优化? [英] How to use profile guided optimizations in g++?

查看:31
本文介绍了如何在 g++ 中使用配置文件引导优化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

另外,谁能给我指出一个关于这个主题的好教程?我找不到.

Also, can anyone point me to a good tutorial on the subject? I can't find any.

推荐答案

-fprofile-generate 将使用分析代码检测应用程序.如果在编译时知道这种使用模式,应用程序将在实际运行时记录可以提高性能的某些事件.可以记录分支、内联的可能性等,但我不确定 GCC 是如何实现这一点的.

-fprofile-generate will instrument the application with profiling code. The application will, while actually running, log certain events that could improve performance if this usage pattern was known at compile time. Branches, possibility for inlining, etc, can all be logged, but I'm not sure in detail how GCC implements this.

程序退出后,会将所有这些数据转储到 *.gcda 文件中,这些文件本质上是用于测试运行的日志数据.使用 -fprofile-use 标志重建应用程序后,GCC 在优化时会考虑 *.gcda 日志数据,通常会显着提高性能.当然,这取决于很多因素.

After the program exits, it will dump all this data into *.gcda files, which are essentially log data for a test run. After rebuilding the application with -fprofile-use flag, GCC will take the *.gcda log data into account when doing its optimizations, usually increasing the performance significantly. Of course, this depends on many factors.

这篇关于如何在 g++ 中使用配置文件引导优化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆