Skip to content

Commit cfd3620

Browse files
peterjc123facebook-github-bot
authored andcommittedSep 9, 2020
Don't use VCOMP if Intel OMP is used (pytorch#44280)
Summary: Fixes pytorch#44096. Pull Request resolved: pytorch#44280 Reviewed By: malfet Differential Revision: D23568557 Pulled By: ezyang fbshipit-source-id: bd627e497a9f71be9ba908852bf3ae437b1a5c94
1 parent d23f317 commit cfd3620

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
 

‎caffe2/CMakeLists.txt

+13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ if(USE_VULKAN)
66
include(../cmake/VulkanCodegen.cmake)
77
endif()
88

9+
# ---[ MSVC OpenMP modification
10+
if(MSVC)
11+
include(../cmake/public/utils.cmake)
12+
endif()
13+
914
# ATen parallelism settings
1015
# OMP - OpenMP for intra-op, native thread pool for inter-op parallelism
1116
# NATIVE - using native thread pool for intra- and inter-op parallelism
@@ -895,6 +900,11 @@ if(USE_OPENMP)
895900
find_package(OpenMP QUIET)
896901
endif()
897902
if(USE_OPENMP AND OPENMP_FOUND)
903+
if(MSVC AND OpenMP_CXX_LIBRARIES MATCHES "libiomp5md\\.lib")
904+
set(AT_MKL_MT 1)
905+
else()
906+
set(AT_MKL_MT 0)
907+
endif()
898908
message(STATUS "pytorch is compiling with OpenMP. \n"
899909
"OpenMP CXX_FLAGS: ${OpenMP_CXX_FLAGS}. \n"
900910
"OpenMP libraries: ${OpenMP_CXX_LIBRARIES}.")
@@ -1385,6 +1395,7 @@ if(BUILD_PYTHON)
13851395
if(NOT MSVC)
13861396
set_target_properties(caffe2_pybind11_state PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
13871397
endif()
1398+
torch_set_target_props(caffe2_pybind11_state)
13881399
set_target_properties(caffe2_pybind11_state PROPERTIES PREFIX "" DEBUG_POSTFIX "")
13891400
set_target_properties(caffe2_pybind11_state PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
13901401
set_target_properties(caffe2_pybind11_state PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")
@@ -1414,6 +1425,7 @@ if(BUILD_PYTHON)
14141425
if(NOT MSVC)
14151426
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
14161427
endif()
1428+
torch_set_target_props(caffe2_pybind11_state_gpu)
14171429
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES PREFIX "" DEBUG_POSTFIX "")
14181430
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
14191431
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")
@@ -1441,6 +1453,7 @@ if(BUILD_PYTHON)
14411453
if(NOT MSVC)
14421454
target_compile_options(caffe2_pybind11_state_hip PRIVATE ${HIP_CXX_FLAGS} -fvisibility=hidden)
14431455
endif()
1456+
torch_set_target_props(caffe2_pybind11_state_hip)
14441457
set_target_properties(caffe2_pybind11_state_hip PROPERTIES PREFIX "")
14451458
set_target_properties(caffe2_pybind11_state_hip PROPERTIES SUFFIX ${PY_EXT_SUFFIX})
14461459
set_target_properties(caffe2_pybind11_state_hip PROPERTIES LINK_FLAGS "${_caffe2_pybind11_state_linker_flags}")

‎modules/detectron/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ if(BUILD_CAFFE2_OPS)
1515
${Detectron_CPU_SRCS}
1616
${Detectron_GPU_SRCS})
1717

18+
torch_set_target_props(caffe2_detectron_ops_gpu)
1819
target_link_libraries(caffe2_detectron_ops_gpu torch ${OpenMP_link})
1920
install(TARGETS caffe2_detectron_ops_gpu DESTINATION lib)
2021
if(MSVC)
@@ -27,6 +28,7 @@ if(BUILD_CAFFE2_OPS)
2728
caffe2_detectron_ops_hip SHARED
2829
${Detectron_CPU_SRCS}
2930
${Detectron_HIP_SRCS})
31+
torch_set_target_props(caffe2_detectron_ops_hip)
3032
target_compile_options(caffe2_detectron_ops_hip PRIVATE ${HIP_CXX_FLAGS})
3133
target_link_libraries(caffe2_detectron_ops_hip torch)
3234
install(TARGETS caffe2_detectron_ops_hip DESTINATION lib)
@@ -36,6 +38,7 @@ if(BUILD_CAFFE2_OPS)
3638
set_target_properties(caffe2_detectron_ops PROPERTIES
3739
VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION})
3840
endif()
41+
torch_set_target_props(caffe2_detectron_ops)
3942
target_link_libraries(caffe2_detectron_ops torch ${OpenMP_link})
4043
install(TARGETS caffe2_detectron_ops DESTINATION lib)
4144
if(MSVC)

0 commit comments

Comments
 (0)