Ask Your Question
0

CMake use -openmp instead of -qopenmp for Intel Compiler

asked 2017-02-15 12:33:29 -0600

lovaj gravatar image

I'm building OpenCV on a Xeon Phi using the Intel Compiler v16. These are the cmake settings:

cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_TBB=OFF -DWITH_OPENMP=ON -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc ..

However, using -DWITH_OPENMP=ON produces the flag -openmp which is depecrated, instead it should use -qopenmp. How can I tell to cmake to use the correct flag?

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
3

answered 2017-02-17 04:27:42 -0600

mshabunin gravatar image

According to script (https://github.com/opencv/opencv/blob...) this flag is set by cmake's own script (for example /usr/share/cmake-3.5/Modules/FindOpenMP.cmake), which in turns tries to compile a piece of code with several flag candidates and chooses first succeeded. It moves most appropriate flag to the beginning of the list to speed up the detection. For Intel compiler, the first priority flag is:

if(WIN32)
  set(OMP_FLAG_Intel "-Qopenmp")
elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "Intel" AND
       "${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528")
  set(OMP_FLAG_Intel "-openmp")
else()
  set(OMP_FLAG_Intel "-qopenmp")
endif()

So, you can provide your own FindOpenMP.cmake script (try to put it to the opencv/cmake folder or to the one of other paths described here) which will set appropriate flags. But I'd recommend you leaving it as is or using TBB.

BTW, RelWithDebInfo is prohibited by OpenCV's cmake scripts, only Debug and Release are available.

edit flag offensive delete link more
0

answered 2017-02-17 07:42:48 -0600

lovaj gravatar image

Updating cmake to a newer version (it was really old mine) solved the problem

edit flag offensive delete link more

Comments

Are you on Windows?

Royi gravatar imageRoyi ( 2018-04-11 23:14:51 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-02-15 12:33:29 -0600

Seen: 1,095 times

Last updated: Feb 17 '17