forked from Eyescale/CMake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindMKL.cmake
202 lines (179 loc) · 4.63 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# - Try to find the Intel Math Kernel Library
# Forked from: https://github.com/openmeeg/openmeeg/blob/master/macros/FindMKL.cmake
# Once done this will define
#
# MKL_FOUND - system has MKL
# MKL_ROOT_DIR - path to the MKL base directory
# MKL_INCLUDE_DIR - the MKL include directory
# MKL_LIBRARIES - MKL libraries
#
# There are few sets of libraries:
# Array indexes modes:
# LP - 32 bit indexes of arrays
# ILP - 64 bit indexes of arrays
# Threading:
# SEQUENTIAL - no threading
# INTEL - Intel threading library
# GNU - GNU threading library
# MPI support
# NOMPI - no MPI support
# INTEL - Intel MPI library
# OPEN - Open MPI library
# SGI - SGI MPT Library
# linux
if(UNIX AND NOT APPLE)
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(MKL_ARCH_DIR "em64t")
else()
set(MKL_ARCH_DIR "32")
endif()
endif()
# macos
if(APPLE)
set(MKL_ARCH_DIR "em64t")
endif()
IF(FORCE_BUILD_32BITS)
set(MKL_ARCH_DIR "32")
ENDIF()
if (WIN32)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
set(MKL_ARCH_DIR "intel64")
else()
set(MKL_ARCH_DIR "ia32")
endif()
endif()
set (MKL_THREAD_VARIANTS SEQUENTIAL GNUTHREAD INTELTHREAD)
set (MKL_MODE_VARIANTS ILP LP)
set (MKL_MPI_VARIANTS NOMPI INTELMPI OPENMPI SGIMPT)
find_path(MKL_ROOT_DIR
include/mkl_cblas.h
PATHS
$ENV{MKLDIR}
/opt/intel/mkl/*/
/opt/intel/cmkl/*/
/Library/Frameworks/Intel_MKL.framework/Versions/Current/lib/universal
"Program Files (x86)/Intel/ComposerXE-2011/mkl"
)
MESSAGE("MKL_ROOT_DIR : ${MKL_ROOT_DIR}") # for debug
find_path(MKL_INCLUDE_DIR
mkl_cblas.h
PATHS
${MKL_ROOT_DIR}/include
${INCLUDE_INSTALL_DIR}
)
find_path(MKL_FFTW_INCLUDE_DIR
fftw3.h
PATH_SUFFIXES fftw
PATHS
${MKL_ROOT_DIR}/include
${INCLUDE_INSTALL_DIR}
NO_DEFAULT_PATH
)
find_library(MKL_CORE_LIBRARY
mkl_core
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
# Threading libraries
find_library(MKL_SEQUENTIAL_LIBRARY
mkl_sequential
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
find_library(MKL_INTELTHREAD_LIBRARY
mkl_intel_thread
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
find_library(MKL_GNUTHREAD_LIBRARY
mkl_gnu_thread
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
# Intel Libraries
IF("${MKL_ARCH_DIR}" STREQUAL "32")
find_library(MKL_LP_LIBRARY
mkl_intel
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
find_library(MKL_ILP_LIBRARY
mkl_intel
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
else()
find_library(MKL_LP_LIBRARY
mkl_intel_lp64
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
find_library(MKL_ILP_LIBRARY
mkl_intel_ilp64
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
ENDIF()
# Lapack
find_library(MKL_LAPACK_LIBRARY
mkl_lapack
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
IF(NOT MKL_LAPACK_LIBRARY)
find_library(MKL_LAPACK_LIBRARY
mkl_lapack95_lp64
PATHS
${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}
${MKL_ROOT_DIR}/lib/
)
ENDIF()
# iomp5
IF("${MKL_ARCH_DIR}" STREQUAL "32")
IF(UNIX AND NOT APPLE)
find_library(MKL_IOMP5_LIBRARY
iomp5
PATHS
${MKL_ROOT_DIR}/../lib/ia32
)
ELSE()
SET(MKL_IOMP5_LIBRARY "") # no need for mac
ENDIF()
else()
IF(UNIX AND NOT APPLE)
find_library(MKL_IOMP5_LIBRARY
iomp5
PATHS
${MKL_ROOT_DIR}/../lib/intel64
)
ELSE()
SET(MKL_IOMP5_LIBRARY "") # no need for mac
ENDIF()
ENDIF()
foreach (MODEVAR ${MKL_MODE_VARIANTS})
foreach (THREADVAR ${MKL_THREAD_VARIANTS})
if (MKL_CORE_LIBRARY AND MKL_${MODEVAR}_LIBRARY AND MKL_${THREADVAR}_LIBRARY)
set(MKL_${MODEVAR}_${THREADVAR}_LIBRARIES
${MKL_${MODEVAR}_LIBRARY} ${MKL_${THREADVAR}_LIBRARY} ${MKL_CORE_LIBRARY}
${MKL_LAPACK_LIBRARY} ${MKL_IOMP5_LIBRARY})
message("${MODEVAR} ${THREADVAR} ${MKL_${MODEVAR}_${THREADVAR}_LIBRARIES}") # for debug
endif()
endforeach()
endforeach()
set(MKL_LIBRARIES ${MKL_LP_SEQUENTIAL_LIBRARIES})
LINK_DIRECTORIES(${MKL_ROOT_DIR}/lib/${MKL_ARCH_DIR}) # hack
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INCLUDE_DIR MKL_LIBRARIES)
mark_as_advanced(MKL_INCLUDE_DIR MKL_LIBRARIES
MKL_CORE_LIBRARY MKL_LP_LIBRARY MKL_ILP_LIBRARY
MKL_SEQUENTIAL_LIBRARY MKL_INTELTHREAD_LIBRARY MKL_GNUTHREAD_LIBRARY
)