Don't use VCOMP if Intel OMP is used (#44280)

Summary:
Fixes https://github.com/pytorch/pytorch/issues/44096.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/44280

Reviewed By: malfet

Differential Revision: D23568557

Pulled By: ezyang

fbshipit-source-id: bd627e497a9f71be9ba908852bf3ae437b1a5c94
This commit is contained in:
peter
2020-09-09 08:06:54 -07:00
committed by Facebook GitHub Bot
parent d23f3170ef
commit cfd3620b76
2 changed files with 16 additions and 0 deletions

View File

@ -6,6 +6,11 @@ if(USE_VULKAN)
include(../cmake/VulkanCodegen.cmake)
endif()
# ---[ MSVC OpenMP modification
if(MSVC)
include(../cmake/public/utils.cmake)
endif()
# ATen parallelism settings
# OMP - OpenMP for intra-op, native thread pool for inter-op parallelism
# NATIVE - using native thread pool for intra- and inter-op parallelism
@ -895,6 +900,11 @@ if(USE_OPENMP)
find_package(OpenMP QUIET)
endif()
if(USE_OPENMP AND OPENMP_FOUND)
if(MSVC AND OpenMP_CXX_LIBRARIES MATCHES "libiomp5md\\.lib")
set(AT_MKL_MT 1)
else()
set(AT_MKL_MT 0)
endif()
message(STATUS "pytorch is compiling with OpenMP. \n"
"OpenMP CXX_FLAGS: ${OpenMP_CXX_FLAGS}. \n"
"OpenMP libraries: ${OpenMP_CXX_LIBRARIES}.")
@ -1385,6 +1395,7 @@ if(BUILD_PYTHON)
if(NOT MSVC)
set_target_properties(caffe2_pybind11_state PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
endif()
torch_set_target_props(caffe2_pybind11_state)
set_target_properties(caffe2_pybind11_state PROPERTIES PREFIX "" DEBUG_POSTFIX "")
set_target_properties(caffe2_pybind11_state PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
set_target_properties(caffe2_pybind11_state PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")
@ -1414,6 +1425,7 @@ if(BUILD_PYTHON)
if(NOT MSVC)
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
endif()
torch_set_target_props(caffe2_pybind11_state_gpu)
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES PREFIX "" DEBUG_POSTFIX "")
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")
@ -1441,6 +1453,7 @@ if(BUILD_PYTHON)
if(NOT MSVC)
target_compile_options(caffe2_pybind11_state_hip PRIVATE ${HIP_CXX_FLAGS} -fvisibility=hidden)
endif()
torch_set_target_props(caffe2_pybind11_state_hip)
set_target_properties(caffe2_pybind11_state_hip PROPERTIES PREFIX "")
set_target_properties(caffe2_pybind11_state_hip PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
set_target_properties(caffe2_pybind11_state_hip PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")

View File

@ -15,6 +15,7 @@ if(BUILD_CAFFE2_OPS)
${Detectron_CPU_SRCS}
${Detectron_GPU_SRCS})
torch_set_target_props(caffe2_detectron_ops_gpu)
target_link_libraries(caffe2_detectron_ops_gpu torch ${OpenMP_link})
install(TARGETS caffe2_detectron_ops_gpu DESTINATION lib)
if(MSVC)
@ -27,6 +28,7 @@ if(BUILD_CAFFE2_OPS)
caffe2_detectron_ops_hip SHARED
${Detectron_CPU_SRCS}
${Detectron_HIP_SRCS})
torch_set_target_props(caffe2_detectron_ops_hip)
target_compile_options(caffe2_detectron_ops_hip PRIVATE ${HIP_CXX_FLAGS})
target_link_libraries(caffe2_detectron_ops_hip torch)
install(TARGETS caffe2_detectron_ops_hip DESTINATION lib)
@ -36,6 +38,7 @@ if(BUILD_CAFFE2_OPS)
set_target_properties(caffe2_detectron_ops PROPERTIES
VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION})
endif()
torch_set_target_props(caffe2_detectron_ops)
target_link_libraries(caffe2_detectron_ops torch ${OpenMP_link})
install(TARGETS caffe2_detectron_ops DESTINATION lib)
if(MSVC)