I'm trying to optimize a fairly complex C++ project (multiple source files, linked to Boost libraries, GSL and OpenCV) using profiling. Using CMake, I first compile with
set(CMAKE_CXX_FLAGS " -O3 -ffast-math -fprofile-generate=profiling -pg -fopenmp ")
After running the resulting executable with typical inputs, I compile with
set(CMAKE_CXX_FLAGS " -O3 -ffast-math -fprofile-use=profiling -fopenmp ")
Compilation fails with a large number of errors like this:
/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
I'm using version 4.8.0 of the GNU compilers. As one can see from the compiler flags, my project uses OpenMP.
What could be causing the corruption of the profile info?