Line 0
Link Here
|
|
|
1 |
# - Find BLAS library |
2 |
# This module finds an installed fortran library that implements the BLAS |
3 |
# linear-algebra interface (see http://www.netlib.org/blas/). |
4 |
# The list of libraries searched for is taken |
5 |
# from the autoconf macro file, acx_blas.m4 (distributed at |
6 |
# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). |
7 |
# |
8 |
# This module sets the following variables: |
9 |
# BLAS_FOUND - set to true if a library implementing the BLAS interface |
10 |
# is found |
11 |
# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l |
12 |
# and -L). |
13 |
# BLAS_LIBRARIES - uncached list of libraries (using full path name) to |
14 |
# link against to use BLAS |
15 |
# BLAS95_LIBRARIES - uncached list of libraries (using full path name) |
16 |
# to link against to use BLAS95 interface |
17 |
# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface |
18 |
# is found |
19 |
# BLA_STATIC if set on this determines what kind of linkage we do (static) |
20 |
# BLA_VENDOR if set checks only the specified vendor, if not set checks |
21 |
# all the posibilities |
22 |
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK |
23 |
########## |
24 |
### List of vendors (BLA_VENDOR) valid in this module |
25 |
## ATLAS, PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model), |
26 |
## Intel( older versions of mkl 32 and 64 bit), ACML,Apple, NAS, Generic |
27 |
# C/CXX should be enabled to use Intel mkl |
28 |
get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) |
29 |
|
30 |
macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) |
31 |
# This macro checks for the existence of the combination of fortran libraries |
32 |
# given by _list. If the combination is found, this macro checks (using the |
33 |
# Check_Fortran_Function_Exists macro) whether can link against that library |
34 |
# combination using the name of a routine given by _name using the linker |
35 |
# flags given by _flags. If the combination of libraries is found and passes |
36 |
# the link test, LIBRARIES is set to the list of complete library paths that |
37 |
# have been found. Otherwise, LIBRARIES is set to FALSE. |
38 |
|
39 |
# N.B. _prefix is the prefix applied to the names of all cached variables that |
40 |
# are generated internally and marked advanced by this macro. |
41 |
|
42 |
set(_libraries_work TRUE) |
43 |
set(${LIBRARIES}) |
44 |
set(_combined_name) |
45 |
foreach(_library ${_list}) |
46 |
set(_combined_name ${_combined_name}_${_library}) |
47 |
|
48 |
if(_libraries_work) |
49 |
if ( WIN32 ) |
50 |
if(BLA_STATIC) |
51 |
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") |
52 |
endif(BLA_STATIC) |
53 |
find_library(${_prefix}_${_library}_LIBRARY |
54 |
NAMES ${_library} |
55 |
PATHS ENV LIB |
56 |
) |
57 |
endif ( WIN32 ) |
58 |
|
59 |
if ( APPLE ) |
60 |
if(BLA_STATIC) |
61 |
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") |
62 |
endif(BLA_STATIC) |
63 |
find_library(${_prefix}_${_library}_LIBRARY |
64 |
NAMES ${_library} |
65 |
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH |
66 |
) |
67 |
|
68 |
else ( APPLE ) |
69 |
if(BLA_STATIC) |
70 |
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") |
71 |
endif(BLA_STATIC) |
72 |
find_library(${_prefix}_${_library}_LIBRARY |
73 |
NAMES ${_library} |
74 |
PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH |
75 |
) |
76 |
endif( APPLE ) |
77 |
mark_as_advanced(${_prefix}_${_library}_LIBRARY) |
78 |
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) |
79 |
set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) |
80 |
endif(_libraries_work) |
81 |
endforeach(_library ${_list}) |
82 |
if(NOT _libraries_work) |
83 |
set(${LIBRARIES} FALSE) |
84 |
endif(NOT _libraries_work) |
85 |
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") |
86 |
endmacro(Check_Fortran_Libraries) |
87 |
|
88 |
set(BLAS_LINKER_FLAGS) |
89 |
set(BLAS_LIBRARIES) |
90 |
set(BLAS95_LIBRARIES) |
91 |
if ($ENV{BLA_VENDOR} MATCHES ".+") |
92 |
set(BLA_VENDOR $ENV{BLA_VENDOR}) |
93 |
else ($ENV{BLA_VENDOR} MATCHES ".+") |
94 |
if(NOT BLA_VENDOR) |
95 |
set(BLA_VENDOR "All") |
96 |
endif(NOT BLA_VENDOR) |
97 |
endif ($ENV{BLA_VENDOR} MATCHES ".+") |
98 |
|
99 |
#BLAS in intel mkl 10 library? (em64t 64bit) |
100 |
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") |
101 |
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) |
102 |
if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) |
103 |
find_package(Threads) |
104 |
else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) |
105 |
find_package(Threads REQUIRED) |
106 |
endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) |
107 |
if (WIN32) |
108 |
if(BLA_F95) |
109 |
if(NOT BLAS95_LIBRARIES) |
110 |
check_fortran_libraries( |
111 |
BLAS95_LIBRARIES |
112 |
BLAS |
113 |
sgemm |
114 |
"" |
115 |
"mkl_blas95;mkl_intel_c;mkl_intel_thread;mkl_core;libguide40" |
116 |
"" |
117 |
) |
118 |
endif(NOT BLAS95_LIBRARIES) |
119 |
else(BLA_F95) |
120 |
if(NOT BLAS_LIBRARIES) |
121 |
check_fortran_libraries( |
122 |
BLAS_LIBRARIES |
123 |
BLAS |
124 |
SGEMM |
125 |
"" |
126 |
"mkl_c_dll;mkl_intel_thread_dll;mkl_core_dll;libguide40" |
127 |
"" |
128 |
) |
129 |
endif(NOT BLAS_LIBRARIES) |
130 |
endif(BLA_F95) |
131 |
else(WIN32) |
132 |
if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") |
133 |
if(BLA_F95) |
134 |
if(NOT BLAS95_LIBRARIES) |
135 |
check_fortran_libraries( |
136 |
BLAS95_LIBRARIES |
137 |
BLAS |
138 |
sgemm |
139 |
"" |
140 |
"mkl_blas95;mkl_intel;mkl_intel_thread;mkl_core;guide" |
141 |
"${CMAKE_THREAD_LIBS_INIT}" |
142 |
) |
143 |
endif(NOT BLAS95_LIBRARIES) |
144 |
else(BLA_F95) |
145 |
if(NOT BLAS_LIBRARIES) |
146 |
check_fortran_libraries( |
147 |
BLAS_LIBRARIES |
148 |
BLAS |
149 |
sgemm |
150 |
"" |
151 |
"mkl_intel;mkl_intel_thread;mkl_core;guide" |
152 |
"${CMAKE_THREAD_LIBS_INIT}" |
153 |
) |
154 |
endif(NOT BLAS_LIBRARIES) |
155 |
endif(BLA_F95) |
156 |
endif (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") |
157 |
if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") |
158 |
if(BLA_F95) |
159 |
if(NOT BLAS95_LIBRARIES) |
160 |
check_fortran_libraries( |
161 |
BLAS95_LIBRARIES |
162 |
BLAS |
163 |
sgemm |
164 |
"" |
165 |
"mkl_blas95;mkl_intel_lp64;mkl_intel_thread;mkl_core;guide" |
166 |
"${CMAKE_THREAD_LIBS_INIT}" |
167 |
) |
168 |
endif(NOT BLAS95_LIBRARIES) |
169 |
else(BLA_F95) |
170 |
if(NOT BLAS_LIBRARIES) |
171 |
check_fortran_libraries( |
172 |
BLAS_LIBRARIES |
173 |
BLAS |
174 |
sgemm |
175 |
"" |
176 |
"mkl_intel_lp64;mkl_intel_thread;mkl_core;guide" |
177 |
"${CMAKE_THREAD_LIBS_INIT}" |
178 |
) |
179 |
endif(NOT BLAS_LIBRARIES) |
180 |
endif(BLA_F95) |
181 |
endif (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") |
182 |
endif (WIN32) |
183 |
#older vesions of intel mkl libs |
184 |
# BLAS in intel mkl library? (shared) |
185 |
if(NOT BLAS_LIBRARIES) |
186 |
check_fortran_libraries( |
187 |
BLAS_LIBRARIES |
188 |
BLAS |
189 |
sgemm |
190 |
"" |
191 |
"mkl;guide" |
192 |
"${CMAKE_THREAD_LIBS_INIT}" |
193 |
) |
194 |
endif(NOT BLAS_LIBRARIES) |
195 |
#BLAS in intel mkl library? (static, 32bit) |
196 |
if(NOT BLAS_LIBRARIES) |
197 |
check_fortran_libraries( |
198 |
BLAS_LIBRARIES |
199 |
BLAS |
200 |
sgemm |
201 |
"" |
202 |
"mkl_ia32;guide" |
203 |
"${CMAKE_THREAD_LIBS_INIT}" |
204 |
) |
205 |
endif(NOT BLAS_LIBRARIES) |
206 |
#BLAS in intel mkl library? (static, em64t 64bit) |
207 |
if(NOT BLAS_LIBRARIES) |
208 |
check_fortran_libraries( |
209 |
BLAS_LIBRARIES |
210 |
BLAS |
211 |
sgemm |
212 |
"" |
213 |
"mkl_em64t;guide" |
214 |
"${CMAKE_THREAD_LIBS_INIT}" |
215 |
) |
216 |
endif(NOT BLAS_LIBRARIES) |
217 |
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) |
218 |
endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") |
219 |
|
220 |
#BLAS in acml library? |
221 |
if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") |
222 |
if(NOT BLAS_LIBRARIES) |
223 |
check_fortran_libraries( |
224 |
BLAS_LIBRARIES |
225 |
BLAS |
226 |
sgemm |
227 |
"" |
228 |
"acml" |
229 |
"" |
230 |
) |
231 |
endif(NOT BLAS_LIBRARIES) |
232 |
endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") |
233 |
|
234 |
# Apple BLAS library? |
235 |
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") |
236 |
if(NOT BLAS_LIBRARIES) |
237 |
check_fortran_libraries( |
238 |
BLAS_LIBRARIES |
239 |
BLAS |
240 |
cblas_dgemm |
241 |
"" |
242 |
"Accelerate" |
243 |
"" |
244 |
) |
245 |
endif(NOT BLAS_LIBRARIES) |
246 |
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") |
247 |
|
248 |
if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") |
249 |
if(NOT BLAS_LIBRARIES) |
250 |
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) |
251 |
check_fortran_libraries( |
252 |
BLAS_LIBRARIES |
253 |
BLAS |
254 |
cblas_dgemm |
255 |
"" |
256 |
"cblas;f77blas;atlas" |
257 |
"" |
258 |
) |
259 |
endif(NOT BLAS_LIBRARIES) |
260 |
endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") |
261 |
|
262 |
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too) |
263 |
if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") |
264 |
if(NOT BLAS_LIBRARIES) |
265 |
check_fortran_libraries( |
266 |
BLAS_LIBRARIES |
267 |
BLAS |
268 |
sgemm |
269 |
"" |
270 |
"sgemm;dgemm;blas" |
271 |
"" |
272 |
) |
273 |
endif(NOT BLAS_LIBRARIES) |
274 |
endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") |
275 |
|
276 |
# BLAS in Alpha CXML library? |
277 |
if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") |
278 |
if(NOT BLAS_LIBRARIES) |
279 |
check_fortran_libraries( |
280 |
BLAS_LIBRARIES |
281 |
BLAS |
282 |
sgemm |
283 |
"" |
284 |
"cxml" |
285 |
"" |
286 |
) |
287 |
endif(NOT BLAS_LIBRARIES) |
288 |
endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") |
289 |
|
290 |
# BLAS in Alpha DXML library? (now called CXML, see above) |
291 |
if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") |
292 |
if(NOT BLAS_LIBRARIES) |
293 |
check_fortran_libraries( |
294 |
BLAS_LIBRARIES |
295 |
BLAS |
296 |
sgemm |
297 |
"" |
298 |
"dxml" |
299 |
"" |
300 |
) |
301 |
endif(NOT BLAS_LIBRARIES) |
302 |
endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") |
303 |
|
304 |
# BLAS in Sun Performance library? |
305 |
if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") |
306 |
if(NOT BLAS_LIBRARIES) |
307 |
check_fortran_libraries( |
308 |
BLAS_LIBRARIES |
309 |
BLAS |
310 |
sgemm |
311 |
"-xlic_lib=sunperf" |
312 |
"sunperf;sunmath" |
313 |
"" |
314 |
) |
315 |
if(BLAS_LIBRARIES) |
316 |
set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") |
317 |
endif(BLAS_LIBRARIES) |
318 |
endif(NOT BLAS_LIBRARIES) |
319 |
endif (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") |
320 |
|
321 |
# BLAS in SCSL library? (SGI/Cray Scientific Library) |
322 |
if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") |
323 |
if(NOT BLAS_LIBRARIES) |
324 |
check_fortran_libraries( |
325 |
BLAS_LIBRARIES |
326 |
BLAS |
327 |
sgemm |
328 |
"" |
329 |
"scsl" |
330 |
"" |
331 |
) |
332 |
endif(NOT BLAS_LIBRARIES) |
333 |
endif (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") |
334 |
|
335 |
# BLAS in SGIMATH library? |
336 |
if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") |
337 |
if(NOT BLAS_LIBRARIES) |
338 |
check_fortran_libraries( |
339 |
BLAS_LIBRARIES |
340 |
BLAS |
341 |
sgemm |
342 |
"" |
343 |
"complib.sgimath" |
344 |
"" |
345 |
) |
346 |
endif(NOT BLAS_LIBRARIES) |
347 |
endif (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") |
348 |
|
349 |
# BLAS in IBM ESSL library? (requires generic BLAS lib, too) |
350 |
if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") |
351 |
if(NOT BLAS_LIBRARIES) |
352 |
check_fortran_libraries( |
353 |
BLAS_LIBRARIES |
354 |
BLAS |
355 |
sgemm |
356 |
"" |
357 |
"essl;blas" |
358 |
"" |
359 |
) |
360 |
endif(NOT BLAS_LIBRARIES) |
361 |
endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") |
362 |
|
363 |
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") |
364 |
if ( NOT BLAS_LIBRARIES ) |
365 |
check_fortran_libraries( |
366 |
BLAS_LIBRARIES |
367 |
BLAS |
368 |
cblas_dgemm |
369 |
"" |
370 |
"vecLib" |
371 |
"" |
372 |
) |
373 |
endif ( NOT BLAS_LIBRARIES ) |
374 |
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") |
375 |
# Generic BLAS library? |
376 |
if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") |
377 |
if(NOT BLAS_LIBRARIES) |
378 |
check_fortran_libraries( |
379 |
BLAS_LIBRARIES |
380 |
BLAS |
381 |
sgemm |
382 |
"" |
383 |
"blas" |
384 |
"" |
385 |
) |
386 |
endif(NOT BLAS_LIBRARIES) |
387 |
endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") |
388 |
|
389 |
if(BLA_F95) |
390 |
if(BLAS95_LIBRARIES) |
391 |
set(BLAS95_FOUND TRUE) |
392 |
else(BLAS95_LIBRARIES) |
393 |
set(BLAS95_FOUND FALSE) |
394 |
endif(BLAS95_LIBRARIES) |
395 |
|
396 |
if(NOT BLAS_FIND_QUIETLY) |
397 |
if(BLAS95_FOUND) |
398 |
message(STATUS "A library with BLAS95 API found.") |
399 |
else(BLAS95_FOUND) |
400 |
if(BLAS_FIND_REQUIRED) |
401 |
message(FATAL_ERROR |
402 |
"A required library with BLAS95 API not found. Please specify library location.") |
403 |
else(BLAS_FIND_REQUIRED) |
404 |
message(STATUS |
405 |
"A library with BLAS95 API not found. Please specify library location.") |
406 |
endif(BLAS_FIND_REQUIRED) |
407 |
endif(BLAS95_FOUND) |
408 |
endif(NOT BLAS_FIND_QUIETLY) |
409 |
set(BLAS_FOUND TRUE) |
410 |
set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") |
411 |
else(BLA_F95) |
412 |
if(BLAS_LIBRARIES) |
413 |
set(BLAS_FOUND TRUE) |
414 |
else(BLAS_LIBRARIES) |
415 |
set(BLAS_FOUND FALSE) |
416 |
endif(BLAS_LIBRARIES) |
417 |
|
418 |
if(NOT BLAS_FIND_QUIETLY) |
419 |
if(BLAS_FOUND) |
420 |
message(STATUS "A library with BLAS API found.") |
421 |
else(BLAS_FOUND) |
422 |
if(BLAS_FIND_REQUIRED) |
423 |
message(FATAL_ERROR |
424 |
"A required library with BLAS API not found. Please specify library location." |
425 |
) |
426 |
else(BLAS_FIND_REQUIRED) |
427 |
message(STATUS |
428 |
"A library with BLAS API not found. Please specify library location." |
429 |
) |
430 |
endif(BLAS_FIND_REQUIRED) |
431 |
endif(BLAS_FOUND) |
432 |
endif(NOT BLAS_FIND_QUIETLY) |
433 |
endif(BLA_F95) |