Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

OpenCV compilation with Intel C++ Compiler

Engin_F_
Beginner
939 Views

Which compiler flags should be used for OpenCV compilation to get best performance from library?

I want to benefit from vectorization properties of compiler and want machine code of OpenCV which fully benefits SSE and AVX instructions.

At least some clues about this issue will be fine for me.

0 Kudos
9 Replies
SergeyKostrov
Valued Contributor II
939 Views
>>Which compiler flags should be used for OpenCV compilation to get best performance from library?.. It would be nice to see a set of Intel C++ compiler options you currently use. Take into account that some Intel C++ compiler options are turned on by default and use icl.exe -help. Here is a list you could try: /O3 /QaxSSE2 and /QaxAVX /Qvec /Qstd=c99 /Qrestrict /Qansi-alias /Qipo /Qunroll=8 /Qopt-block-factor:3 /Qopt-mem-layout-trans:3 /Qopt-prefetch:4
0 Kudos
SergeyKostrov
Valued Contributor II
940 Views
Here are two sets of compiler options to be considered: [ Intel C++ compiler ] /O3 /Oi /Ot /Oy /GF /MT /GS- /fp:fast=2 /W5 /Wp64 /Zi /Gr /TP /Qopenmp /Qfp-speculation:fast /Qopt-matmul /Qparallel /Qstd=c++0x /Qrestrict /Qunroll:4 /Qopt-block-factor:64 /Qopt-streaming-stores:auto [ Microsoft C++ compiler ] /O2 /Oi /Ot /Oy /GF /Gm /MT /GS- /fp:fast /openmp /W4 /Wp64 /Zi /TP /errorReport:prompt Note: /Ox ( Full Optimization ) could be used instead of /O2
0 Kudos
Engin_F_
Beginner
939 Views

I will give them a try and share the results, thank you so much.

0 Kudos
SergeyKostrov
Valued Contributor II
940 Views
>>...I will give them a try and share the results... The best way to continue is to add, or change, one option at a time with verification in Release Configuration that performance doesn't get worse. If you try all of them at the same time and performance gets worse then you won't know which option(s) is responsible for negative impact.
0 Kudos
Engin_F_
Beginner
940 Views

Himm that's a very good idea. I will give them try in a batch. Whenever I complete my profiler, I will compile different builds of OpenCV by using this way and profile these different builds. I will share profiler results with you.

Thank you so much for your concern.

0 Kudos
Bruno_A_1
Beginner
939 Views

Is there any recommendations based on personal experience? I'm currently compiling opencv with icc and would appreciate any pointers. 

thanks

0 Kudos
Bernard
Valued Contributor I
940 Views

Try to compile openCV programs with various compiler settings and later test your code with Intel VTune profiler.

0 Kudos
Bernard
Valued Contributor I
938 Views

 

>>>fp:fast=2>>>

Instead of /fp:fast compiler option you can use more safe /fp:precise. 

0 Kudos
Dinesh_C_
Beginner
940 Views

HI,

   I want to compile  Opencv codes for image processing in Ubuntu, but when i use only the processor to run the code it's slow and for more reliability i want to use the Intel C/C++ compiler what are the changes that should be made in order to make it work. i found the Cmake cchanges and tried it but still it did'nt get through it completely.

Thanks,

Dinesh.

0 Kudos
Reply