You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

743 lines
22 KiB

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
9 years ago
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # FindBLAS
  5. # --------
  6. #
  7. # Find BLAS library
  8. #
  9. # This module finds an installed fortran library that implements the
  10. # BLAS linear-algebra interface (see http://www.netlib.org/blas/). The
  11. # list of libraries searched for is taken from the autoconf macro file,
  12. # acx_blas.m4 (distributed at
  13. # http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
  14. #
  15. # This module sets the following variables:
  16. #
  17. # ::
  18. #
  19. # BLAS_FOUND - set to true if a library implementing the BLAS interface
  20. # is found
  21. # BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
  22. # and -L).
  23. # BLAS_LIBRARIES - uncached list of libraries (using full path name) to
  24. # link against to use BLAS (may be empty if compiler implicitly links
  25. # BLAS)
  26. # BLAS95_LIBRARIES - uncached list of libraries (using full path name)
  27. # to link against to use BLAS95 interface
  28. # BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
  29. # is found
  30. #
  31. # The following variables can be used to control this module:
  32. #
  33. # ::
  34. #
  35. # BLA_STATIC if set on this determines what kind of linkage we do (static)
  36. # BLA_VENDOR if set checks only the specified vendor, if not set checks
  37. # all the possibilities
  38. # BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
  39. # BLA_PREFER_PKGCONFIG if set pkg-config will be used to search for a BLAS
  40. # library first and if one is found that is preferred
  41. #
  42. # List of vendors (BLA_VENDOR) valid in this module:
  43. #
  44. # * Goto
  45. # * OpenBLAS
  46. # * FLAME
  47. # * ATLAS PhiPACK
  48. # * CXML
  49. # * DXML
  50. # * SunPerf
  51. # * SCSL
  52. # * SGIMATH
  53. # * IBMESSL
  54. # * Intel10_32 (intel mkl v10 32 bit)
  55. # * Intel10_64lp (intel mkl v10+ 64 bit, threaded code, lp64 model)
  56. # * Intel10_64lp_seq (intel mkl v10+ 64 bit, sequential code, lp64 model)
  57. # * Intel10_64ilp (intel mkl v10+ 64 bit, threaded code, ilp64 model)
  58. # * Intel10_64ilp_seq (intel mkl v10+ 64 bit, sequential code, ilp64 model)
  59. # * Intel (older versions of mkl 32 and 64 bit)
  60. # * ACML
  61. # * ACML_MP
  62. # * ACML_GPU
  63. # * Apple
  64. # * NAS
  65. # * Generic
  66. #
  67. # .. note::
  68. #
  69. # C/CXX should be enabled to use Intel mkl
  70. #
  71. include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
  72. include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
  73. include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
  74. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  75. cmake_push_check_state()
  76. set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
  77. set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  78. # Check the language being used
  79. if( NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED) )
  80. if(BLAS_FIND_REQUIRED)
  81. message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
  82. else()
  83. message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)")
  84. return()
  85. endif()
  86. endif()
  87. if(BLA_PREFER_PKGCONFIG)
  88. find_package(PkgConfig)
  89. pkg_check_modules(PKGC_BLAS blas)
  90. if(PKGC_BLAS_FOUND)
  91. set(BLAS_FOUND ${PKGC_BLAS_FOUND})
  92. set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}")
  93. return()
  94. endif()
  95. endif()
  96. macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
  97. # This macro checks for the existence of the combination of fortran libraries
  98. # given by _list. If the combination is found, this macro checks (using the
  99. # Check_Fortran_Function_Exists macro) whether can link against that library
  100. # combination using the name of a routine given by _name using the linker
  101. # flags given by _flags. If the combination of libraries is found and passes
  102. # the link test, LIBRARIES is set to the list of complete library paths that
  103. # have been found. Otherwise, LIBRARIES is set to FALSE.
  104. # N.B. _prefix is the prefix applied to the names of all cached variables that
  105. # are generated internally and marked advanced by this macro.
  106. set(_libdir ${ARGN})
  107. set(_libraries_work TRUE)
  108. set(${LIBRARIES})
  109. set(_combined_name)
  110. if (NOT _libdir)
  111. if (WIN32)
  112. set(_libdir ENV LIB)
  113. elseif (APPLE)
  114. set(_libdir ENV DYLD_LIBRARY_PATH)
  115. else ()
  116. set(_libdir ENV LD_LIBRARY_PATH)
  117. endif ()
  118. endif ()
  119. foreach(_library ${_list})
  120. set(_combined_name ${_combined_name}_${_library})
  121. if(_libraries_work)
  122. if (BLA_STATIC)
  123. if (WIN32)
  124. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
  125. endif ()
  126. if (APPLE)
  127. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
  128. else ()
  129. set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  130. endif ()
  131. else ()
  132. if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
  133. # for ubuntu's libblas3gf and liblapack3gf packages
  134. set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
  135. endif ()
  136. endif ()
  137. find_library(${_prefix}_${_library}_LIBRARY
  138. NAMES ${_library}
  139. PATHS ${_libdir}
  140. )
  141. mark_as_advanced(${_prefix}_${_library}_LIBRARY)
  142. set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
  143. set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
  144. endif()
  145. endforeach()
  146. if(_libraries_work)
  147. # Test this combination of libraries.
  148. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_thread})
  149. # message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
  150. if (CMAKE_Fortran_COMPILER_LOADED)
  151. check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
  152. else()
  153. check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
  154. endif()
  155. set(CMAKE_REQUIRED_LIBRARIES)
  156. mark_as_advanced(${_prefix}${_combined_name}_WORKS)
  157. set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
  158. endif()
  159. if(_libraries_work)
  160. if("${_list}" STREQUAL "")
  161. set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
  162. endif()
  163. else()
  164. set(${LIBRARIES} FALSE)
  165. endif()
  166. #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
  167. endmacro()
  168. set(BLAS_LINKER_FLAGS)
  169. set(BLAS_LIBRARIES)
  170. set(BLAS95_LIBRARIES)
  171. if (NOT $ENV{BLA_VENDOR} STREQUAL "")
  172. set(BLA_VENDOR $ENV{BLA_VENDOR})
  173. else ()
  174. if(NOT BLA_VENDOR)
  175. set(BLA_VENDOR "All")
  176. endif()
  177. endif ()
  178. if (BLA_VENDOR STREQUAL "All")
  179. if(NOT BLAS_LIBRARIES)
  180. # Implicitly linked BLAS libraries
  181. check_fortran_libraries(
  182. BLAS_LIBRARIES
  183. BLAS
  184. sgemm
  185. ""
  186. ""
  187. ""
  188. )
  189. endif()
  190. endif ()
  191. #BLAS in intel mkl 10+ library? (em64t 64bit)
  192. if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
  193. if (NOT BLAS_LIBRARIES)
  194. if (BLA_VENDOR MATCHES "_64ilp")
  195. set(BLAS_mkl_ILP_MODE "ilp64")
  196. else ()
  197. set(BLAS_mkl_ILP_MODE "lp64")
  198. endif ()
  199. if (NOT WIN32)
  200. set(LM "-lm")
  201. endif ()
  202. if (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
  203. if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
  204. find_package(Threads)
  205. else()
  206. find_package(Threads REQUIRED)
  207. endif()
  208. set(BLAS_SEARCH_LIBS "")
  209. if(BLA_F95)
  210. set(BLAS_mkl_SEARCH_SYMBOL sgemm_f95)
  211. set(_LIBRARIES BLAS95_LIBRARIES)
  212. if (WIN32)
  213. if (BLA_STATIC)
  214. set(BLAS_mkl_DLL_SUFFIX "")
  215. else()
  216. set(BLAS_mkl_DLL_SUFFIX "_dll")
  217. endif()
  218. # Find the main file (32-bit or 64-bit)
  219. set(BLAS_SEARCH_LIBS_WIN_MAIN "")
  220. if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  221. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  222. "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
  223. endif()
  224. if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
  225. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  226. "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
  227. endif ()
  228. # Add threading/sequential libs
  229. set(BLAS_SEARCH_LIBS_WIN_THREAD "")
  230. if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
  231. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  232. "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
  233. endif()
  234. if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
  235. # old version
  236. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  237. "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  238. # mkl >= 10.3
  239. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  240. "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  241. endif()
  242. # Cartesian product of the above
  243. foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
  244. foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
  245. list(APPEND BLAS_SEARCH_LIBS
  246. "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
  247. endforeach()
  248. endforeach()
  249. else ()
  250. if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  251. list(APPEND BLAS_SEARCH_LIBS
  252. "mkl_blas95 mkl_intel mkl_intel_thread mkl_core guide")
  253. endif ()
  254. if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
  255. # old version
  256. list(APPEND BLAS_SEARCH_LIBS
  257. "mkl_blas95 mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide")
  258. # mkl >= 10.3
  259. if (CMAKE_C_COMPILER MATCHES ".+gcc")
  260. list(APPEND BLAS_SEARCH_LIBS
  261. "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp")
  262. else ()
  263. list(APPEND BLAS_SEARCH_LIBS
  264. "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5")
  265. endif ()
  266. endif ()
  267. if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
  268. list(APPEND BLAS_SEARCH_LIBS
  269. "mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core")
  270. endif ()
  271. endif ()
  272. else ()
  273. set(BLAS_mkl_SEARCH_SYMBOL sgemm)
  274. set(_LIBRARIES BLAS_LIBRARIES)
  275. if (WIN32)
  276. if (BLA_STATIC)
  277. set(BLAS_mkl_DLL_SUFFIX "")
  278. else()
  279. set(BLAS_mkl_DLL_SUFFIX "_dll")
  280. endif()
  281. # Find the main file (32-bit or 64-bit)
  282. set(BLAS_SEARCH_LIBS_WIN_MAIN "")
  283. if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  284. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  285. "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
  286. endif()
  287. if (BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
  288. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  289. "mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
  290. endif ()
  291. # Add threading/sequential libs
  292. set(BLAS_SEARCH_LIBS_WIN_THREAD "")
  293. if (NOT BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
  294. # old version
  295. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  296. "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  297. # mkl >= 10.3
  298. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  299. "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  300. endif()
  301. if (BLA_VENDOR MATCHES "_seq$" OR BLA_VENDOR STREQUAL "All")
  302. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  303. "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
  304. endif()
  305. # Cartesian product of the above
  306. foreach (MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
  307. foreach (THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
  308. list(APPEND BLAS_SEARCH_LIBS
  309. "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
  310. endforeach()
  311. endforeach()
  312. else ()
  313. if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  314. list(APPEND BLAS_SEARCH_LIBS
  315. "mkl_intel mkl_intel_thread mkl_core guide")
  316. endif ()
  317. if (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
  318. # old version
  319. list(APPEND BLAS_SEARCH_LIBS
  320. "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core guide")
  321. # mkl >= 10.3
  322. if (CMAKE_C_COMPILER MATCHES ".+gcc")
  323. list(APPEND BLAS_SEARCH_LIBS
  324. "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_gnu_thread mkl_core gomp")
  325. else ()
  326. list(APPEND BLAS_SEARCH_LIBS
  327. "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_intel_thread mkl_core iomp5")
  328. endif ()
  329. endif ()
  330. if (BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
  331. list(APPEND BLAS_SEARCH_LIBS
  332. "mkl_intel_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core")
  333. endif ()
  334. #older vesions of intel mkl libs
  335. if (BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All")
  336. list(APPEND BLAS_SEARCH_LIBS
  337. "mkl")
  338. list(APPEND BLAS_SEARCH_LIBS
  339. "mkl_ia32")
  340. list(APPEND BLAS_SEARCH_LIBS
  341. "mkl_em64t")
  342. endif ()
  343. endif ()
  344. endif ()
  345. foreach (IT ${BLAS_SEARCH_LIBS})
  346. string(REPLACE " " ";" SEARCH_LIBS ${IT})
  347. if (NOT ${_LIBRARIES})
  348. check_fortran_libraries(
  349. ${_LIBRARIES}
  350. BLAS
  351. ${BLAS_mkl_SEARCH_SYMBOL}
  352. ""
  353. "${SEARCH_LIBS}"
  354. "${CMAKE_THREAD_LIBS_INIT};${LM}"
  355. )
  356. endif ()
  357. endforeach ()
  358. endif ()
  359. unset(BLAS_mkl_ILP_MODE)
  360. endif ()
  361. endif ()
  362. if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
  363. if(NOT BLAS_LIBRARIES)
  364. # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
  365. check_fortran_libraries(
  366. BLAS_LIBRARIES
  367. BLAS
  368. sgemm
  369. ""
  370. "goto2"
  371. ""
  372. )
  373. endif()
  374. endif ()
  375. if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
  376. if(NOT BLAS_LIBRARIES)
  377. # OpenBLAS (http://www.openblas.net)
  378. check_fortran_libraries(
  379. BLAS_LIBRARIES
  380. BLAS
  381. sgemm
  382. ""
  383. "openblas"
  384. ""
  385. )
  386. endif()
  387. endif ()
  388. if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")
  389. if(NOT BLAS_LIBRARIES)
  390. # FLAME's blis library (https://github.com/flame/blis)
  391. check_fortran_libraries(
  392. BLAS_LIBRARIES
  393. BLAS
  394. sgemm
  395. ""
  396. "blis"
  397. ""
  398. )
  399. endif()
  400. endif ()
  401. if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
  402. if(NOT BLAS_LIBRARIES)
  403. # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
  404. check_fortran_libraries(
  405. BLAS_LIBRARIES
  406. BLAS
  407. dgemm
  408. ""
  409. "f77blas;atlas"
  410. ""
  411. )
  412. endif()
  413. endif ()
  414. # BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
  415. if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
  416. if(NOT BLAS_LIBRARIES)
  417. check_fortran_libraries(
  418. BLAS_LIBRARIES
  419. BLAS
  420. sgemm
  421. ""
  422. "sgemm;dgemm;blas"
  423. ""
  424. )
  425. endif()
  426. endif ()
  427. # BLAS in Alpha CXML library?
  428. if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
  429. if(NOT BLAS_LIBRARIES)
  430. check_fortran_libraries(
  431. BLAS_LIBRARIES
  432. BLAS
  433. sgemm
  434. ""
  435. "cxml"
  436. ""
  437. )
  438. endif()
  439. endif ()
  440. # BLAS in Alpha DXML library? (now called CXML, see above)
  441. if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
  442. if(NOT BLAS_LIBRARIES)
  443. check_fortran_libraries(
  444. BLAS_LIBRARIES
  445. BLAS
  446. sgemm
  447. ""
  448. "dxml"
  449. ""
  450. )
  451. endif()
  452. endif ()
  453. # BLAS in Sun Performance library?
  454. if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
  455. if(NOT BLAS_LIBRARIES)
  456. check_fortran_libraries(
  457. BLAS_LIBRARIES
  458. BLAS
  459. sgemm
  460. "-xlic_lib=sunperf"
  461. "sunperf;sunmath"
  462. ""
  463. )
  464. if(BLAS_LIBRARIES)
  465. set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
  466. endif()
  467. endif()
  468. endif ()
  469. # BLAS in SCSL library? (SGI/Cray Scientific Library)
  470. if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
  471. if(NOT BLAS_LIBRARIES)
  472. check_fortran_libraries(
  473. BLAS_LIBRARIES
  474. BLAS
  475. sgemm
  476. ""
  477. "scsl"
  478. ""
  479. )
  480. endif()
  481. endif ()
  482. # BLAS in SGIMATH library?
  483. if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
  484. if(NOT BLAS_LIBRARIES)
  485. check_fortran_libraries(
  486. BLAS_LIBRARIES
  487. BLAS
  488. sgemm
  489. ""
  490. "complib.sgimath"
  491. ""
  492. )
  493. endif()
  494. endif ()
  495. # BLAS in IBM ESSL library? (requires generic BLAS lib, too)
  496. if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
  497. if(NOT BLAS_LIBRARIES)
  498. check_fortran_libraries(
  499. BLAS_LIBRARIES
  500. BLAS
  501. sgemm
  502. ""
  503. "essl;blas"
  504. ""
  505. )
  506. endif()
  507. endif ()
  508. #BLAS in acml library?
  509. if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
  510. if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
  511. ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
  512. ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
  513. )
  514. # try to find acml in "standard" paths
  515. if( WIN32 )
  516. file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" )
  517. else()
  518. file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" )
  519. endif()
  520. if( WIN32 )
  521. file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" )
  522. else()
  523. file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" )
  524. endif()
  525. list(GET _ACML_ROOT 0 _ACML_ROOT)
  526. list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
  527. if( _ACML_ROOT )
  528. get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH )
  529. if( SIZEOF_INTEGER EQUAL 8 )
  530. set( _ACML_PATH_SUFFIX "_int64" )
  531. else()
  532. set( _ACML_PATH_SUFFIX "" )
  533. endif()
  534. if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
  535. set( _ACML_COMPILER32 "ifort32" )
  536. set( _ACML_COMPILER64 "ifort64" )
  537. elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
  538. set( _ACML_COMPILER32 "sun32" )
  539. set( _ACML_COMPILER64 "sun64" )
  540. elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" )
  541. set( _ACML_COMPILER32 "pgi32" )
  542. if( WIN32 )
  543. set( _ACML_COMPILER64 "win64" )
  544. else()
  545. set( _ACML_COMPILER64 "pgi64" )
  546. endif()
  547. elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" )
  548. # 32 bit builds not supported on Open64 but for code simplicity
  549. # We'll just use the same directory twice
  550. set( _ACML_COMPILER32 "open64_64" )
  551. set( _ACML_COMPILER64 "open64_64" )
  552. elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
  553. set( _ACML_COMPILER32 "nag32" )
  554. set( _ACML_COMPILER64 "nag64" )
  555. else()
  556. set( _ACML_COMPILER32 "gfortran32" )
  557. set( _ACML_COMPILER64 "gfortran64" )
  558. endif()
  559. if( BLA_VENDOR STREQUAL "ACML_MP" )
  560. set(_ACML_MP_LIB_DIRS
  561. "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
  562. "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" )
  563. else()
  564. set(_ACML_LIB_DIRS
  565. "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
  566. "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" )
  567. endif()
  568. endif()
  569. elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
  570. set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
  571. endif()
  572. if( BLA_VENDOR STREQUAL "ACML_MP" )
  573. foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS})
  574. check_fortran_libraries (
  575. BLAS_LIBRARIES
  576. BLAS
  577. sgemm
  578. "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS}
  579. )
  580. if( BLAS_LIBRARIES )
  581. break()
  582. endif()
  583. endforeach()
  584. elseif( BLA_VENDOR STREQUAL "ACML_GPU" )
  585. foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS})
  586. check_fortran_libraries (
  587. BLAS_LIBRARIES
  588. BLAS
  589. sgemm
  590. "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS}
  591. )
  592. if( BLAS_LIBRARIES )
  593. break()
  594. endif()
  595. endforeach()
  596. else()
  597. foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} )
  598. check_fortran_libraries (
  599. BLAS_LIBRARIES
  600. BLAS
  601. sgemm
  602. "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS}
  603. )
  604. if( BLAS_LIBRARIES )
  605. break()
  606. endif()
  607. endforeach()
  608. endif()
  609. # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
  610. if(NOT BLAS_LIBRARIES)
  611. check_fortran_libraries(
  612. BLAS_LIBRARIES
  613. BLAS
  614. sgemm
  615. ""
  616. "acml;acml_mv"
  617. ""
  618. )
  619. endif()
  620. if(NOT BLAS_LIBRARIES)
  621. check_fortran_libraries(
  622. BLAS_LIBRARIES
  623. BLAS
  624. sgemm
  625. ""
  626. "acml_mp;acml_mv"
  627. ""
  628. )
  629. endif()
  630. if(NOT BLAS_LIBRARIES)
  631. check_fortran_libraries(
  632. BLAS_LIBRARIES
  633. BLAS
  634. sgemm
  635. ""
  636. "acml;acml_mv;CALBLAS"
  637. ""
  638. )
  639. endif()
  640. endif () # ACML
  641. # Apple BLAS library?
  642. if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
  643. if(NOT BLAS_LIBRARIES)
  644. check_fortran_libraries(
  645. BLAS_LIBRARIES
  646. BLAS
  647. dgemm
  648. ""
  649. "Accelerate"
  650. ""
  651. )
  652. endif()
  653. endif ()
  654. if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
  655. if ( NOT BLAS_LIBRARIES )
  656. check_fortran_libraries(
  657. BLAS_LIBRARIES
  658. BLAS
  659. dgemm
  660. ""
  661. "vecLib"
  662. ""
  663. )
  664. endif ()
  665. endif ()
  666. # Generic BLAS library?
  667. if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
  668. if(NOT BLAS_LIBRARIES)
  669. check_fortran_libraries(
  670. BLAS_LIBRARIES
  671. BLAS
  672. sgemm
  673. ""
  674. "blas"
  675. ""
  676. )
  677. endif()
  678. endif ()
  679. if(BLA_F95)
  680. find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES)
  681. set(BLAS95_FOUND ${BLAS_FOUND})
  682. if(BLAS_FOUND)
  683. set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
  684. endif()
  685. else()
  686. find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES)
  687. endif()
  688. # On compilers that implicitly link BLAS (such as ftn, cc, and CC on Cray HPC machines)
  689. # we used a placeholder for empty BLAS_LIBRARIES to get through our logic above.
  690. if (BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
  691. set(BLAS_LIBRARIES "")
  692. endif()
  693. cmake_pop_check_state()
  694. set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})