首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >g++和CMake的配置文件信息已损坏

g++和CMake的配置文件信息已损坏
EN

Stack Overflow用户
提问于 2013-06-01 09:40:20
回答 1查看 1.9K关注 0票数 4

我正在尝试使用性能分析来优化一个相当复杂的C++项目(多个源文件,链接到Boost库、GSL和OpenCV)。使用CMake,我首先使用

代码语言:javascript
运行
复制
set(CMAKE_CXX_FLAGS " -O3 -ffast-math -fprofile-generate=profiling -pg -fopenmp ")

在使用典型输入运行生成的可执行文件之后,我使用以下命令进行编译

代码语言:javascript
运行
复制
set(CMAKE_CXX_FLAGS " -O3 -ffast-math -fprofile-use=profiling -fopenmp ")

编译失败,出现大量错误,如下所示:

代码语言:javascript
运行
复制
/n/user/projects/project_name/src/foo.cpp: In member function ‘double TLinearInterp::operator()(double) const’:
/n/user/projects/project_name/src/foo.cpp:86:1: error: corrupted profile info: profile data is not flow-consistent
 }
 ^
/n/user/projects/project_name/src/foo.cpp:86:1: error: corrupted profile info: number of executions for edge 2-7 thought to be -7232
/n/user/projects/project_name/src/foo.cpp:86:1: error: corrupted profile info: number of executions for edge 2-3 thought to be 20996551
/n/user/projects/project_name/src/foo.cpp:86:1: error: corrupted profile info: number of executions for edge 3-7 thought to be -28135
/n/user/projects/project_name/src/foo.cpp:86:1: error: corrupted profile info: number of executions for edge 3-4 thought to be 21024686

我使用的是GNU编译器的4.8.0版本。从编译器标志可以看出,我的项目使用了OpenMP。

是什么导致了个人资料信息的损坏?

EN

回答 1

Stack Overflow用户

发布于 2014-12-31 13:26:51

我怀疑是多线程导致了这个问题,因为您使用的是-fopenmp

在较高的级别上,-fprofile-generate使编译器使用计数器增量来检测您的程序。这些增量不是线程安全的,因此您的测试运行可能会产生损坏的分析数据。

您可以通过将-fprofile-correction传递给编译器1来解决此问题。或者,您可以在尝试PGO时禁用-fopenmp/multithreading。我已经成功地使用了第一种方法。

1

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16868235

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档