| 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 possibilities |
| 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 |
## Goto,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 |
## Intel10_64lp_seq (intel mkl v10 64 bit,sequential code, lp64 model), |
| 27 |
## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic |
| 28 |
# C/CXX should be enabled to use Intel mkl |
| 29 |
|
| 30 |
#============================================================================= |
| 31 |
# Copyright 2007-2009 Kitware, Inc. |
| 32 |
# |
| 33 |
# Redistribution and use in source and binary forms, with or without |
| 34 |
# modification, are permitted provided that the following conditions |
| 35 |
# are met: |
| 36 |
# |
| 37 |
# 1. Redistributions of source code must retain the copyright |
| 38 |
# notice, this list of conditions and the following disclaimer. |
| 39 |
# 2. Redistributions in binary form must reproduce the copyright |
| 40 |
# notice, this list of conditions and the following disclaimer in the |
| 41 |
# documentation and/or other materials provided with the distribution. |
| 42 |
# 3. The name of the author may not be used to endorse or promote products |
| 43 |
# derived from this software without specific prior written permission. |
| 44 |
# |
| 45 |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 46 |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 47 |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 48 |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 49 |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 50 |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 51 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 52 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 53 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 54 |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 55 |
#============================================================================= |
| 56 |
|
| 57 |
include(CheckFunctionExists) |
| 58 |
include(CheckFortranFunctionExists) |
| 59 |
|
| 60 |
set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 61 |
|
| 62 |
# Check the language being used |
| 63 |
get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) |
| 64 |
if( _LANGUAGES_ MATCHES Fortran AND CMAKE_Fortran_COMPILER_WORKS ) |
| 65 |
set( _CHECK_FORTRAN TRUE ) |
| 66 |
elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) ) |
| 67 |
set( _CHECK_FORTRAN FALSE ) |
| 68 |
else() |
| 69 |
if(BLAS_FIND_REQUIRED) |
| 70 |
message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.") |
| 71 |
else(BLAS_FIND_REQUIRED) |
| 72 |
message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)") |
| 73 |
return() |
| 74 |
endif(BLAS_FIND_REQUIRED) |
| 75 |
endif( ) |
| 76 |
|
| 77 |
macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) |
| 78 |
# This macro checks for the existence of the combination of fortran libraries |
| 79 |
# given by _list. If the combination is found, this macro checks (using the |
| 80 |
# Check_Fortran_Function_Exists macro) whether can link against that library |
| 81 |
# combination using the name of a routine given by _name using the linker |
| 82 |
# flags given by _flags. If the combination of libraries is found and passes |
| 83 |
# the link test, LIBRARIES is set to the list of complete library paths that |
| 84 |
# have been found. Otherwise, LIBRARIES is set to FALSE. |
| 85 |
|
| 86 |
# N.B. _prefix is the prefix applied to the names of all cached variables that |
| 87 |
# are generated internally and marked advanced by this macro. |
| 88 |
|
| 89 |
set(_libdir ${ARGN}) |
| 90 |
|
| 91 |
set(_libraries_work TRUE) |
| 92 |
set(${LIBRARIES}) |
| 93 |
set(_combined_name) |
| 94 |
if (NOT _libdir) |
| 95 |
if (WIN32) |
| 96 |
set(_libdir ENV LIB) |
| 97 |
elseif (APPLE) |
| 98 |
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH) |
| 99 |
else () |
| 100 |
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH) |
| 101 |
endif () |
| 102 |
endif () |
| 103 |
|
| 104 |
foreach(_library ${_list}) |
| 105 |
set(_combined_name ${_combined_name}_${_library}) |
| 106 |
|
| 107 |
if(_libraries_work) |
| 108 |
if (BLA_STATIC) |
| 109 |
if (WIN32) |
| 110 |
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 111 |
endif ( WIN32 ) |
| 112 |
if (APPLE) |
| 113 |
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 114 |
else (APPLE) |
| 115 |
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 116 |
endif (APPLE) |
| 117 |
else (BLA_STATIC) |
| 118 |
if (CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 119 |
# for ubuntu's libblas3gf and liblapack3gf packages |
| 120 |
#set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) |
| 121 |
endif () |
| 122 |
endif (BLA_STATIC) |
| 123 |
find_library(${_prefix}_${_library}_LIBRARY |
| 124 |
NAMES ${_library} |
| 125 |
PATHS ${_libdir} |
| 126 |
) |
| 127 |
mark_as_advanced(${_prefix}_${_library}_LIBRARY) |
| 128 |
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) |
| 129 |
set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) |
| 130 |
endif(_libraries_work) |
| 131 |
endforeach(_library ${_list}) |
| 132 |
if(_libraries_work) |
| 133 |
# Test this combination of libraries. |
| 134 |
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread}) |
| 135 |
# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") |
| 136 |
|
| 137 |
# GNW: Add special flags for static BLAS libraries for function check |
| 138 |
if(BLA_STATIC AND UNIX) |
| 139 |
set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group ${${LIBRARIES}};-Wl,--end-group" ${_thread}) |
| 140 |
endif() |
| 141 |
|
| 142 |
if (_CHECK_FORTRAN) |
| 143 |
check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) |
| 144 |
else() |
| 145 |
check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) |
| 146 |
endif() |
| 147 |
|
| 148 |
set(CMAKE_REQUIRED_LIBRARIES) |
| 149 |
mark_as_advanced(${_prefix}${_combined_name}_WORKS) |
| 150 |
set(_libraries_work ${${_prefix}${_combined_name}_WORKS}) |
| 151 |
endif(_libraries_work) |
| 152 |
if(NOT _libraries_work) |
| 153 |
set(${LIBRARIES} FALSE) |
| 154 |
endif(NOT _libraries_work) |
| 155 |
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") |
| 156 |
endmacro(Check_Fortran_Libraries) |
| 157 |
|
| 158 |
set(BLAS_LINKER_FLAGS) |
| 159 |
set(BLAS_LIBRARIES) |
| 160 |
set(BLAS95_LIBRARIES) |
| 161 |
if ($ENV{BLA_VENDOR} MATCHES ".+") |
| 162 |
set(BLA_VENDOR $ENV{BLA_VENDOR}) |
| 163 |
else ($ENV{BLA_VENDOR} MATCHES ".+") |
| 164 |
if(NOT BLA_VENDOR) |
| 165 |
set(BLA_VENDOR "All") |
| 166 |
endif(NOT BLA_VENDOR) |
| 167 |
endif ($ENV{BLA_VENDOR} MATCHES ".+") |
| 168 |
|
| 169 |
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") |
| 170 |
if(NOT BLAS_LIBRARIES) |
| 171 |
# gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) |
| 172 |
check_fortran_libraries( |
| 173 |
BLAS_LIBRARIES |
| 174 |
BLAS |
| 175 |
sgemm |
| 176 |
"" |
| 177 |
"goto2" |
| 178 |
"" |
| 179 |
) |
| 180 |
endif(NOT BLAS_LIBRARIES) |
| 181 |
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") |
| 182 |
|
| 183 |
if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") |
| 184 |
if(NOT BLAS_LIBRARIES) |
| 185 |
# openblas (http://www.openblas.net) |
| 186 |
check_fortran_libraries( |
| 187 |
BLAS_LIBRARIES |
| 188 |
BLAS |
| 189 |
sgemm |
| 190 |
"" |
| 191 |
"openblas" |
| 192 |
"" |
| 193 |
) |
| 194 |
endif(NOT BLAS_LIBRARIES) |
| 195 |
endif (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") |
| 196 |
|
| 197 |
if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") |
| 198 |
if(NOT BLAS_LIBRARIES) |
| 199 |
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) |
| 200 |
check_fortran_libraries( |
| 201 |
BLAS_LIBRARIES |
| 202 |
BLAS |
| 203 |
dgemm |
| 204 |
"" |
| 205 |
"cblas;f77blas;atlas" |
| 206 |
"" |
| 207 |
) |
| 208 |
endif(NOT BLAS_LIBRARIES) |
| 209 |
endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") |
| 210 |
|
| 211 |
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too) |
| 212 |
if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") |
| 213 |
if(NOT BLAS_LIBRARIES) |
| 214 |
check_fortran_libraries( |
| 215 |
BLAS_LIBRARIES |
| 216 |
BLAS |
| 217 |
sgemm |
| 218 |
"" |
| 219 |
"sgemm;dgemm;blas" |
| 220 |
"" |
| 221 |
) |
| 222 |
endif(NOT BLAS_LIBRARIES) |
| 223 |
endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") |
| 224 |
|
| 225 |
# BLAS in Alpha CXML library? |
| 226 |
if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") |
| 227 |
if(NOT BLAS_LIBRARIES) |
| 228 |
check_fortran_libraries( |
| 229 |
BLAS_LIBRARIES |
| 230 |
BLAS |
| 231 |
sgemm |
| 232 |
"" |
| 233 |
"cxml" |
| 234 |
"" |
| 235 |
) |
| 236 |
endif(NOT BLAS_LIBRARIES) |
| 237 |
endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") |
| 238 |
|
| 239 |
# BLAS in Alpha DXML library? (now called CXML, see above) |
| 240 |
if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") |
| 241 |
if(NOT BLAS_LIBRARIES) |
| 242 |
check_fortran_libraries( |
| 243 |
BLAS_LIBRARIES |
| 244 |
BLAS |
| 245 |
sgemm |
| 246 |
"" |
| 247 |
"dxml" |
| 248 |
"" |
| 249 |
) |
| 250 |
endif(NOT BLAS_LIBRARIES) |
| 251 |
endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") |
| 252 |
|
| 253 |
# BLAS in Sun Performance library? |
| 254 |
if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") |
| 255 |
if(NOT BLAS_LIBRARIES) |
| 256 |
check_fortran_libraries( |
| 257 |
BLAS_LIBRARIES |
| 258 |
BLAS |
| 259 |
sgemm |
| 260 |
"-xlic_lib=sunperf" |
| 261 |
"sunperf;sunmath" |
| 262 |
"" |
| 263 |
) |
| 264 |
if(BLAS_LIBRARIES) |
| 265 |
set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") |
| 266 |
endif(BLAS_LIBRARIES) |
| 267 |
endif(NOT BLAS_LIBRARIES) |
| 268 |
endif (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") |
| 269 |
|
| 270 |
# BLAS in SCSL library? (SGI/Cray Scientific Library) |
| 271 |
if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") |
| 272 |
if(NOT BLAS_LIBRARIES) |
| 273 |
check_fortran_libraries( |
| 274 |
BLAS_LIBRARIES |
| 275 |
BLAS |
| 276 |
sgemm |
| 277 |
"" |
| 278 |
"scsl" |
| 279 |
"" |
| 280 |
) |
| 281 |
endif(NOT BLAS_LIBRARIES) |
| 282 |
endif (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") |
| 283 |
|
| 284 |
# BLAS in SGIMATH library? |
| 285 |
if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") |
| 286 |
if(NOT BLAS_LIBRARIES) |
| 287 |
check_fortran_libraries( |
| 288 |
BLAS_LIBRARIES |
| 289 |
BLAS |
| 290 |
sgemm |
| 291 |
"" |
| 292 |
"complib.sgimath" |
| 293 |
"" |
| 294 |
) |
| 295 |
endif(NOT BLAS_LIBRARIES) |
| 296 |
endif (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") |
| 297 |
|
| 298 |
# BLAS in IBM ESSL library? (requires generic BLAS lib, too) |
| 299 |
if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") |
| 300 |
if(NOT BLAS_LIBRARIES) |
| 301 |
check_fortran_libraries( |
| 302 |
BLAS_LIBRARIES |
| 303 |
BLAS |
| 304 |
sgemm |
| 305 |
"" |
| 306 |
"essl;blas" |
| 307 |
"" |
| 308 |
) |
| 309 |
endif(NOT BLAS_LIBRARIES) |
| 310 |
endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") |
| 311 |
|
| 312 |
#BLAS in acml library? |
| 313 |
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") |
| 314 |
if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR |
| 315 |
((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR |
| 316 |
((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) |
| 317 |
) |
| 318 |
# try to find acml in "standard" paths |
| 319 |
if( WIN32 ) |
| 320 |
file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) |
| 321 |
else() |
| 322 |
file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) |
| 323 |
endif() |
| 324 |
if( WIN32 ) |
| 325 |
file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) |
| 326 |
else() |
| 327 |
file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) |
| 328 |
endif() |
| 329 |
list(GET _ACML_ROOT 0 _ACML_ROOT) |
| 330 |
list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) |
| 331 |
if( _ACML_ROOT ) |
| 332 |
get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) |
| 333 |
if( SIZEOF_INTEGER EQUAL 8 ) |
| 334 |
set( _ACML_PATH_SUFFIX "_int64" ) |
| 335 |
else() |
| 336 |
set( _ACML_PATH_SUFFIX "" ) |
| 337 |
endif() |
| 338 |
if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) |
| 339 |
set( _ACML_COMPILER32 "ifort32" ) |
| 340 |
set( _ACML_COMPILER64 "ifort64" ) |
| 341 |
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) |
| 342 |
set( _ACML_COMPILER32 "sun32" ) |
| 343 |
set( _ACML_COMPILER64 "sun64" ) |
| 344 |
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) |
| 345 |
set( _ACML_COMPILER32 "pgi32" ) |
| 346 |
if( WIN32 ) |
| 347 |
set( _ACML_COMPILER64 "win64" ) |
| 348 |
else() |
| 349 |
set( _ACML_COMPILER64 "pgi64" ) |
| 350 |
endif() |
| 351 |
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) |
| 352 |
# 32 bit builds not supported on Open64 but for code simplicity |
| 353 |
# We'll just use the same directory twice |
| 354 |
set( _ACML_COMPILER32 "open64_64" ) |
| 355 |
set( _ACML_COMPILER64 "open64_64" ) |
| 356 |
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) |
| 357 |
set( _ACML_COMPILER32 "nag32" ) |
| 358 |
set( _ACML_COMPILER64 "nag64" ) |
| 359 |
else() #if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" ) |
| 360 |
set( _ACML_COMPILER32 "gfortran32" ) |
| 361 |
set( _ACML_COMPILER64 "gfortran64" ) |
| 362 |
endif() |
| 363 |
|
| 364 |
if( BLA_VENDOR STREQUAL "ACML_MP" ) |
| 365 |
set(_ACML_MP_LIB_DIRS |
| 366 |
"${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" |
| 367 |
"${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) |
| 368 |
else() #if( _BLAS_VENDOR STREQUAL "ACML" ) |
| 369 |
set(_ACML_LIB_DIRS |
| 370 |
"${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" |
| 371 |
"${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) |
| 372 |
endif() |
| 373 |
endif() |
| 374 |
elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) |
| 375 |
set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) |
| 376 |
endif() |
| 377 |
|
| 378 |
if( BLA_VENDOR STREQUAL "ACML_MP" ) |
| 379 |
foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) |
| 380 |
check_fortran_libraries ( |
| 381 |
BLAS_LIBRARIES |
| 382 |
BLAS |
| 383 |
sgemm |
| 384 |
"" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} |
| 385 |
) |
| 386 |
if( BLAS_LIBRARIES ) |
| 387 |
break() |
| 388 |
endif() |
| 389 |
endforeach() |
| 390 |
elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) |
| 391 |
foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) |
| 392 |
check_fortran_libraries ( |
| 393 |
BLAS_LIBRARIES |
| 394 |
BLAS |
| 395 |
sgemm |
| 396 |
"" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} |
| 397 |
) |
| 398 |
if( BLAS_LIBRARIES ) |
| 399 |
break() |
| 400 |
endif() |
| 401 |
endforeach() |
| 402 |
else() #if( _BLAS_VENDOR STREQUAL "ACML" ) |
| 403 |
foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) |
| 404 |
check_fortran_libraries ( |
| 405 |
BLAS_LIBRARIES |
| 406 |
BLAS |
| 407 |
sgemm |
| 408 |
"" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} |
| 409 |
) |
| 410 |
if( BLAS_LIBRARIES ) |
| 411 |
break() |
| 412 |
endif() |
| 413 |
endforeach() |
| 414 |
endif() |
| 415 |
|
| 416 |
# Either acml or acml_mp should be in LD_LIBRARY_PATH but not both |
| 417 |
if(NOT BLAS_LIBRARIES) |
| 418 |
check_fortran_libraries( |
| 419 |
BLAS_LIBRARIES |
| 420 |
BLAS |
| 421 |
sgemm |
| 422 |
"" |
| 423 |
"acml;acml_mv" |
| 424 |
"" |
| 425 |
) |
| 426 |
endif(NOT BLAS_LIBRARIES) |
| 427 |
if(NOT BLAS_LIBRARIES) |
| 428 |
check_fortran_libraries( |
| 429 |
BLAS_LIBRARIES |
| 430 |
BLAS |
| 431 |
sgemm |
| 432 |
"" |
| 433 |
"acml_mp;acml_mv" |
| 434 |
"" |
| 435 |
) |
| 436 |
endif(NOT BLAS_LIBRARIES) |
| 437 |
if(NOT BLAS_LIBRARIES) |
| 438 |
check_fortran_libraries( |
| 439 |
BLAS_LIBRARIES |
| 440 |
BLAS |
| 441 |
sgemm |
| 442 |
"" |
| 443 |
"acml;acml_mv;CALBLAS" |
| 444 |
"" |
| 445 |
) |
| 446 |
endif(NOT BLAS_LIBRARIES) |
| 447 |
endif () # ACML |
| 448 |
|
| 449 |
# Apple BLAS library? |
| 450 |
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") |
| 451 |
if(NOT BLAS_LIBRARIES) |
| 452 |
check_fortran_libraries( |
| 453 |
BLAS_LIBRARIES |
| 454 |
BLAS |
| 455 |
dgemm |
| 456 |
"" |
| 457 |
"Accelerate" |
| 458 |
"" |
| 459 |
) |
| 460 |
endif(NOT BLAS_LIBRARIES) |
| 461 |
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") |
| 462 |
|
| 463 |
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") |
| 464 |
if ( NOT BLAS_LIBRARIES ) |
| 465 |
check_fortran_libraries( |
| 466 |
BLAS_LIBRARIES |
| 467 |
BLAS |
| 468 |
dgemm |
| 469 |
"" |
| 470 |
"vecLib" |
| 471 |
"" |
| 472 |
) |
| 473 |
endif ( NOT BLAS_LIBRARIES ) |
| 474 |
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") |
| 475 |
# Generic BLAS library? |
| 476 |
if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") |
| 477 |
if(NOT BLAS_LIBRARIES) |
| 478 |
check_fortran_libraries( |
| 479 |
BLAS_LIBRARIES |
| 480 |
BLAS |
| 481 |
sgemm |
| 482 |
"" |
| 483 |
"blas" |
| 484 |
"" |
| 485 |
) |
| 486 |
endif(NOT BLAS_LIBRARIES) |
| 487 |
endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") |
| 488 |
|
| 489 |
#BLAS in intel mkl 10 library? (em64t 64bit) |
| 490 |
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") |
| 491 |
if (NOT WIN32) |
| 492 |
set(LM "-lm") |
| 493 |
endif () |
| 494 |
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) |
| 495 |
if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) |
| 496 |
find_package(Threads) |
| 497 |
else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) |
| 498 |
find_package(Threads REQUIRED) |
| 499 |
endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) |
| 500 |
|
| 501 |
set(BLAS_SEARCH_LIBS "") |
| 502 |
|
| 503 |
if(BLA_F95) |
| 504 |
set(BLAS_mkl_SEARCH_SYMBOL SGEMM) |
| 505 |
set(_LIBRARIES BLAS95_LIBRARIES) |
| 506 |
if (WIN32) |
| 507 |
list(APPEND BLAS_SEARCH_LIBS |
| 508 |
"mkl_blas95 mkl_intel_c mkl_intel_thread mkl_core libguide40") |
| 509 |
else (WIN32) |
| 510 |
if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") |
| 511 |
list(APPEND BLAS_SEARCH_LIBS |
| 512 |
"mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide") |
| 513 |
endif () |
| 514 |
if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") |
| 515 |
# old version |
| 516 |
list(APPEND BLAS_SEARCH_LIBS |
| 517 |
"mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide") |
| 518 |
|
| 519 |
# mkl >= 10.3 |
| 520 |
if (CMAKE_C_COMPILER MATCHES ".+gcc.*") |
| 521 |
list(APPEND BLAS_SEARCH_LIBS |
| 522 |
"mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core") |
| 523 |
set(LM "${LM};-lgomp") |
| 524 |
else () |
| 525 |
list(APPEND BLAS_SEARCH_LIBS |
| 526 |
"mkl_blas95_lp64 mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") |
| 527 |
endif () |
| 528 |
endif () |
| 529 |
endif (WIN32) |
| 530 |
if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") |
| 531 |
list(APPEND BLAS_SEARCH_LIBS |
| 532 |
"mkl_blas95_lp64 mkl_intel_lp64 mkl_sequential mkl_core") |
| 533 |
endif () |
| 534 |
else (BLA_F95) |
| 535 |
set(BLAS_mkl_SEARCH_SYMBOL sgemm) |
| 536 |
set(_LIBRARIES BLAS_LIBRARIES) |
| 537 |
if (WIN32) |
| 538 |
list(APPEND BLAS_SEARCH_LIBS |
| 539 |
"mkl_c_dll mkl_intel_thread_dll mkl_core_dll libguide40") |
| 540 |
else (WIN32) |
| 541 |
if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") |
| 542 |
list(APPEND BLAS_SEARCH_LIBS |
| 543 |
"mkl_intel mkl_intel_thread mkl_core guide") |
| 544 |
endif () |
| 545 |
if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") |
| 546 |
|
| 547 |
# old version |
| 548 |
list(APPEND BLAS_SEARCH_LIBS |
| 549 |
"mkl_intel_lp64 mkl_intel_thread mkl_core guide") |
| 550 |
|
| 551 |
# mkl >= 10.3 |
| 552 |
if (CMAKE_C_COMPILER MATCHES ".+gcc.*") |
| 553 |
list(APPEND BLAS_SEARCH_LIBS |
| 554 |
"mkl_intel_lp64 mkl_gnu_thread mkl_core") |
| 555 |
set(LM "${LM};-lgomp") |
| 556 |
else () |
| 557 |
list(APPEND BLAS_SEARCH_LIBS |
| 558 |
"mkl_intel_lp64 mkl_intel_thread mkl_core iomp5") |
| 559 |
endif () |
| 560 |
endif () |
| 561 |
|
| 562 |
#older vesions of intel mkl libs |
| 563 |
if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All") |
| 564 |
list(APPEND BLAS_SEARCH_LIBS |
| 565 |
"mkl") |
| 566 |
list(APPEND BLAS_SEARCH_LIBS |
| 567 |
"mkl_ia32") |
| 568 |
list(APPEND BLAS_SEARCH_LIBS |
| 569 |
"mkl_em64t") |
| 570 |
endif () |
| 571 |
endif (WIN32) |
| 572 |
if (BLA_VENDOR STREQUAL "Intel10_64lp_seq" OR BLA_VENDOR STREQUAL "All") |
| 573 |
list(APPEND BLAS_SEARCH_LIBS |
| 574 |
"mkl_intel_lp64 mkl_sequential mkl_core") |
| 575 |
endif () |
| 576 |
endif (BLA_F95) |
| 577 |
|
| 578 |
foreach (IT ${BLAS_SEARCH_LIBS}) |
| 579 |
string(REPLACE " " ";" SEARCH_LIBS ${IT}) |
| 580 |
if (${_LIBRARIES}) |
| 581 |
else () |
| 582 |
check_fortran_libraries( |
| 583 |
${_LIBRARIES} |
| 584 |
BLAS |
| 585 |
${BLAS_mkl_SEARCH_SYMBOL} |
| 586 |
"" |
| 587 |
"${SEARCH_LIBS}" |
| 588 |
"${CMAKE_THREAD_LIBS_INIT};${LM}" |
| 589 |
) |
| 590 |
endif () |
| 591 |
endforeach () |
| 592 |
|
| 593 |
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) |
| 594 |
endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") |
| 595 |
|
| 596 |
|
| 597 |
if(BLA_F95) |
| 598 |
if(BLAS95_LIBRARIES) |
| 599 |
set(BLAS95_FOUND TRUE) |
| 600 |
else(BLAS95_LIBRARIES) |
| 601 |
set(BLAS95_FOUND FALSE) |
| 602 |
endif(BLAS95_LIBRARIES) |
| 603 |
|
| 604 |
if(NOT BLAS_FIND_QUIETLY) |
| 605 |
if(BLAS95_FOUND) |
| 606 |
message(STATUS "A library with BLAS95 API found.") |
| 607 |
else(BLAS95_FOUND) |
| 608 |
if(BLAS_FIND_REQUIRED) |
| 609 |
message(FATAL_ERROR |
| 610 |
"A required library with BLAS95 API not found. Please specify library location.") |
| 611 |
else(BLAS_FIND_REQUIRED) |
| 612 |
message(STATUS |
| 613 |
"A library with BLAS95 API not found. Please specify library location.") |
| 614 |
endif(BLAS_FIND_REQUIRED) |
| 615 |
endif(BLAS95_FOUND) |
| 616 |
endif(NOT BLAS_FIND_QUIETLY) |
| 617 |
set(BLAS_FOUND TRUE) |
| 618 |
set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") |
| 619 |
else(BLA_F95) |
| 620 |
if(BLAS_LIBRARIES) |
| 621 |
set(BLAS_FOUND TRUE) |
| 622 |
else(BLAS_LIBRARIES) |
| 623 |
set(BLAS_FOUND FALSE) |
| 624 |
endif(BLAS_LIBRARIES) |
| 625 |
|
| 626 |
if(NOT BLAS_FIND_QUIETLY) |
| 627 |
if(BLAS_FOUND) |
| 628 |
message(STATUS "Found BLAS: ${BLAS_LIBRARIES}") |
| 629 |
else(BLAS_FOUND) |
| 630 |
if(BLAS_FIND_REQUIRED) |
| 631 |
message(FATAL_ERROR |
| 632 |
"A required library with BLAS API not found. Please specify library location." |
| 633 |
) |
| 634 |
else(BLAS_FIND_REQUIRED) |
| 635 |
message(STATUS |
| 636 |
"A library with BLAS API not found. Please specify library location." |
| 637 |
) |
| 638 |
endif(BLAS_FIND_REQUIRED) |
| 639 |
endif(BLAS_FOUND) |
| 640 |
endif(NOT BLAS_FIND_QUIETLY) |
| 641 |
endif(BLA_F95) |
| 642 |
|
| 643 |
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) |