2

I'm trying to profile OpenCV using Intel VTune Amplifier. In this page, there is a list of compiler options suggested to obtain the best analysis.

As you can see, it's a mix of debug flags (e.g. -g) and optimization flags (e.g. -O2 or higher), so we can say it suggest "a release mode with debugging information".

In order to profile OpenCV with VTune, I think I have to build it with these options too. However, OpenCV is built with CMAKE, and using cmake -D CMAKE_BUILD_TYPE=Release will produce optimization flags (though I don't know which ones, I suppose -O3 or similars) without debugging options and viceversa using cmake -D CMAKE_BUILD_TYPE=Debug.

In conclusion, it seems that I can't build OpenCV with both -g and -O2 flags, which are both highly recommended for profiling application using VTune. Am I right?

How can I solve this?

justHelloWorld
  • 6,478
  • 8
  • 58
  • 138

1 Answers1

3

https://cmake.org/cmake/help/v3.0/variable/CMAKE_BUILD_TYPE.html

Use CMAKE_BUILD_TYPE=RelWithDebInfo to get both optimization flags and debug info.

xaxxon
  • 19,189
  • 5
  • 50
  • 80
  • Sir, you saved my day, thank you. Does this include `-O0` option? Because citing [this](https://software.intel.com/en-us/node/605665): "do not use Debug Build or `-O0`" – justHelloWorld Feb 04 '17 at 12:50
  • `make VERBOSE=1` will show you the commands it runs so you can see exactly what flags are used. -O0 is no optimization, so it doesn't seem like a release build would have that, but just check to see for yourself to make sure. – xaxxon Feb 04 '17 at 13:10