-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindMKL.cmake
94 lines (84 loc) · 2.85 KB
/
FindMKL.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Find the Intel MKL (Math Kernel Library)
#
# MKL_FOUND - System has MKL
# MKL_INCLUDE_DIRS - MKL include files directories
# MKL_LIBRARIES - The MKL libraries
#
# The environment variable MKLROOT is used to find the installation location.
# If the environment variable is not set we'll look for it in the default installation locations.
#
# Usage:
#
# find_package(MKL)
# if(MKL_FOUND)
# target_link_libraries(TARGET ${MKL_LIBRARIES})
# endif()
# Currently we take a couple of assumptions:
#
# 1. We only use the sequential version of the MKL
# 2. We only use 64bit
#
find_path(MKL_ROOT_DIR
include/mkl.h
PATHS
$ENV{MKLROOT}
"C:/IntelSWTools/compilers_and_libraries/windows/mkl/"
"C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl"
"C:/Intel/oneAPI/mkl/latest"
$ENV{CONDA_PREFIX} # conda environments are accessible here (including base)
$ENV{CONDA} # search for conda libs in Azure pipelines
$ENV{CONDA}/Library # same, but for Win
/opt/intel/compilers_and_libraries/linux/mkl # Intel ICC on Linux
/opt/intel/compilers_and_libraries/mac/mkl # Intel ICC on Mac
)
find_path(MKL_INCLUDE_DIR
mkl.h
PATHS
${MKL_ROOT_DIR}/include
)
if(WIN32)
set(MKL_SEARCH_LIB mkl_core.lib)
if(MULTITHREADING)
message("MKL Multithreading mode")
set(MKL_LIBS mkl_intel_lp64.lib mkl_core.lib mkl_intel_thread.lib)
else()
message("MKL Sequential mode")
set(MKL_LIBS mkl_intel_lp64.lib mkl_core.lib mkl_sequential.lib)
endif()
elseif(APPLE)
set(MKL_SEARCH_LIB libmkl_core.a)
if(MULTITHREADING)
message("MKL Multithreading mode")
set(MKL_LIBS libmkl_intel_lp64.a libmkl_core.a libmkl_intel_thread.a)
else()
message("MKL Sequential mode")
set(MKL_LIBS libmkl_intel_ilp64.a libmkl_core.a libmkl_sequential.a)
endif()
else() # Linux
set(MKL_SEARCH_LIB libmkl_core.a)
if(MULTITHREADING)
message("MKL Multithreading mode")
set(MKL_LIBS libmkl_intel_ilp64.a libmkl_intel_thread.a libmkl_core.a libmkl_intel_thread.a)
else()
message("MKL Sequential mode")
set(MKL_LIBS libmkl_intel_ilp64.a libmkl_sequential.a libmkl_core.a libmkl_sequential.a)
endif()
endif()
find_path(MKL_LIB_SEARCHPATH
${MKL_SEARCH_LIB}
PATHS
${MKL_ROOT_DIR}/lib/intel64
${MKL_ROOT_DIR}/lib
)
foreach (LIB ${MKL_LIBS})
find_library(${LIB}_PATH ${LIB} PATHS ${MKL_LIB_SEARCHPATH})
if(${LIB}_PATH)
set(MKL_LIBRARIES ${MKL_LIBRARIES} ${${LIB}_PATH})
message(STATUS "Found MKL ${LIB} in: ${${LIB}_PATH}")
else()
message(STATUS "Could not find ${LIB}: disabling MKL")
endif()
endforeach()
set(MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR})
include_directories(${MKL_INCLUDE_DIRS})
set(INAC_DEPENDENCY_LIBS ${INAC_DEPENDENCY_LIBS} ${MKL_LIBRARIES})