Revert "fix some MKL detection issues of CMake (#94402)"

This reverts commit 7ef46d40a1.

Reverted https://github.com/pytorch/pytorch/pull/94402 on behalf of https://github.com/malfet due to Broke binary builds, see https://github.com/pytorch/pytorch/issues/94751#issuecomment-1428562517
This commit is contained in:
PyTorch MergeBot 2023-02-13 22:09:40 +00:00
parent 2db12e3844
commit e743d316e2
3 changed files with 18 additions and 15 deletions

View File

@ -217,7 +217,7 @@ elseif(BLAS STREQUAL "MKL")
message(STATUS "MKL OpenMP type: ${MKL_OPENMP_TYPE}") message(STATUS "MKL OpenMP type: ${MKL_OPENMP_TYPE}")
message(STATUS "MKL OpenMP library: ${MKL_OPENMP_LIBRARY}") message(STATUS "MKL OpenMP library: ${MKL_OPENMP_LIBRARY}")
include_directories(AFTER SYSTEM ${MKL_INCLUDE_DIR}) include_directories(AFTER SYSTEM ${MKL_INCLUDE_DIR})
list(APPEND Caffe2_DEPENDENCY_LIBS caffe2::mkl) list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS caffe2::mkl)
set(CAFFE2_USE_MKL ON) set(CAFFE2_USE_MKL ON)
set(BLAS_INFO "mkl") set(BLAS_INFO "mkl")
set(BLAS_FOUND 1) set(BLAS_FOUND 1)

View File

@ -41,11 +41,10 @@ IF (WIN32)
ELSE (WIN32) ELSE (WIN32)
SET(DEFAULT_INTEL_COMPILER_DIR "/opt/intel") SET(DEFAULT_INTEL_COMPILER_DIR "/opt/intel")
SET(DEFAULT_INTEL_MKL_DIR "/opt/intel/mkl") SET(DEFAULT_INTEL_MKL_DIR "/opt/intel/mkl")
SET(DEFAULT_INTEL_ONEAPI_DIR "/opt/intel/oneapi") if (EXISTS "/opt/intel/oneapi")
if (EXISTS "${DEFAULT_INTEL_ONEAPI_DIR}") SET(DEFAULT_INTEL_COMPILER_DIR "/opt/intel/oneapi")
SET(DEFAULT_INTEL_COMPILER_DIR "${DEFAULT_INTEL_ONEAPI_DIR}") if (EXISTS "/opt/intel/oneapi/mkl/latest")
if (EXISTS "${DEFAULT_INTEL_ONEAPI_DIR}/mkl/latest") SET(DEFAULT_INTEL_MKL_DIR "/opt/intel/oneapi/mkl/latest")
SET(DEFAULT_INTEL_MKL_DIR "${DEFAULT_INTEL_ONEAPI_DIR}/mkl/latest")
endif() endif()
endif() endif()
ENDIF (WIN32) ENDIF (WIN32)
@ -380,7 +379,7 @@ ENDIF (NOT MKL_LIBRARIES)
# Include files # Include files
IF (MKL_LIBRARIES) IF (MKL_LIBRARIES)
FIND_PATH(MKL_INCLUDE_DIR NAMES "mkl_cblas.h" PATHS "/usr/include/mkl") FIND_PATH(MKL_INCLUDE_DIR "mkl_cblas.h")
MARK_AS_ADVANCED(MKL_INCLUDE_DIR) MARK_AS_ADVANCED(MKL_INCLUDE_DIR)
ENDIF (MKL_LIBRARIES) ENDIF (MKL_LIBRARIES)

View File

@ -227,9 +227,8 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
# http://openmp.llvm.org/ # http://openmp.llvm.org/
# #
# So here, before we test each flag combination, we first try directly # So here, before we test each flag combination, we first try directly
# linking against any `libomp` MKL has linked to (if any and when MKL is # linking against any `libomp` MKL has found (if any). This allows us to
# specified). This allows us to do sensible things in tricky (yet common) # do sensible things in tricky (yet common) conditions like:
# conditions like:
# - using `clang` (so no native GNU OpenMP), and # - using `clang` (so no native GNU OpenMP), and
# - having `brew` `libomp` installed at `/usr/local/`, and # - having `brew` `libomp` installed at `/usr/local/`, and
# - having `conda` `mkl` installed at `$HOME/conda/`, with includes a copy # - having `conda` `mkl` installed at `$HOME/conda/`, with includes a copy
@ -237,14 +236,19 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
# Rather than blindly picking one, we pick what ever `FindMKL.cmake` choses # Rather than blindly picking one, we pick what ever `FindMKL.cmake` choses
# to avoid conflicts. # to avoid conflicts.
# #
# Crucially, we only do so for non-GNU compilers. For GNU ones,
# `FindMKL.cmake` calls `FindOpenMP.cmake` when trying to find `gomp` and # `FindMKL.cmake` calls `FindOpenMP.cmake` when trying to find `gomp` and
# thus will cause infinite recursion if this is not taken care of. Therefore, # thus will cause infinite recursion if this is not taken care of. Moreover,
# we record an internal flag to detect repeatedly inclusion. # for them, since the compiler provices the OpenMP library, it is most
# likely that only one viable gomp library can be found in search path by
# `FindOpenMP.cmake`, so the chance of having conflicts is slow.
#
# TODO: refactor to solve this weird dependency where
# - for non-GNU, FindOpenMP.cmake replies on FindMKL.cmake to finish first, but
# - for GNU, FindMKL.cmake replies on FindOpenMP.cmake to finish first.
if(NOT "${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "GNU" AND BLAS STREQUAL "MKL" AND NOT IN_FIND_OMP) if(NOT "${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "GNU")
set(IN_FIND_OMP ON CACHE BOOL "" FORCE)
find_package(MKL QUIET) find_package(MKL QUIET)
unset(IN_FIND_OMP CACHE)
if(MKL_FOUND AND MKL_OPENMP_LIBRARY) if(MKL_FOUND AND MKL_OPENMP_LIBRARY)
# If we already link OpenMP via MKL, use that. Otherwise at run-time # If we already link OpenMP via MKL, use that. Otherwise at run-time
# OpenMP will complain about being initialized twice (OMP: Error #15), # OpenMP will complain about being initialized twice (OMP: Error #15),