Reputation: 13182
I must use Microsoft Visual C++ 2013 to build a project that uses OpenMP and links to the Intel MKL library, which also uses OpenMP. The issue is that Visual C++ 2013 uses OpenMP 2.0, while MKL is built with OpenMP 4.x.
Everything seems to work fine, even if this could be a false impression.
I get some of these warnings:
warning C4005: 'HUGE_VALF' : macro redefinition
I cannot just disable these warnings. How can I fix them?
As indicated in the answers, I have to exclude Microsoft's own OpenMP implementation and use Intel's one only. So I added this to my CMakeLists.txt file:
# Disable Microsoft's default OpenMP v.2 inclusion
set_target_properties(${PROJECT_LIB} PROPERTIES LINK_FLAGS /nodefaultlib:vcomp)
set_target_properties(${PROJECT_LIB} PROPERTIES LINK_FLAGS /nodefaultlib:vcompd)
set_target_properties(${PROJECT_LIB} PROPERTIES LINK_FLAGS libiomp5md.lib)
However I still get the same warnings...
Upvotes: 0
Views: 366
Reputation: 13182
Following Jim Cownie answer, to exclude the old Microsoft's OpenMP from a project and use Intel's, this is the syntax:
cl /MD /openmp hello.cpp /link /nodefaultlib:vcomp /nodefaultlib:vcompd libiomp5md.lib
which excludes MSVC OpenMP (vcomp.lib vcompd.lib) and connects Intel OpenMP (Version TR4: Version 5.0) (libiomp5md.lib)
Reference: "OpenMP use from INTEL"
Upvotes: 0
Reputation: 2869
You need to be very careful and ensure that there is only a single OpenMP runtime library linked into your code. If you don't you are almost certain to get twice as many threads as you should have, and consequently over-subscription of the hardware and poor performance.
Intel recognised this problem, so the Intel openMP runtime library ("libiomp5") provides the runtime interfaces needed by code compiled by the Microsoft compiler. You can therefore link against the Intel runtime and all should be well.
Upvotes: 1
Reputation: 581
I am not sure if that helps, but I already met with such a problem in the past. The following article (https://software.intel.com/en-us/articles/limits1120-error-identifier-builtin-nanf-is-undefined) suggested some workarounds.
Upvotes: 1