FindBLAS.cmake 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343
  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. Find Basic Linear Algebra Subprograms (BLAS) library
  7. This module finds an installed Fortran library that implements the
  8. `BLAS linear-algebra interface`_.
  9. At least one of the ``C``, ``CXX``, or ``Fortran`` languages must be enabled.
  10. .. _`BLAS linear-algebra interface`: http://www.netlib.org/blas/
  11. Input Variables
  12. ^^^^^^^^^^^^^^^
  13. The following variables may be set to influence this module's behavior:
  14. ``BLA_STATIC``
  15. if ``ON`` use static linkage
  16. ``BLA_VENDOR``
  17. Set to one of the :ref:`BLAS/LAPACK Vendors` to search for BLAS only
  18. from the specified vendor. If not set, all vendors are considered.
  19. ``BLA_F95``
  20. if ``ON`` tries to find the BLAS95 interfaces
  21. ``BLA_PREFER_PKGCONFIG``
  22. .. versionadded:: 3.11
  23. if set ``pkg-config`` will be used to search for a BLAS library first
  24. and if one is found that is preferred
  25. ``BLA_SIZEOF_INTEGER``
  26. .. versionadded:: 3.22
  27. Specify the BLAS/LAPACK library integer size:
  28. ``4``
  29. Search for a BLAS/LAPACK with 32-bit integer interfaces.
  30. ``8``
  31. Search for a BLAS/LAPACK with 64-bit integer interfaces.
  32. ``ANY``
  33. Search for any BLAS/LAPACK.
  34. Most likely, a BLAS/LAPACK with 32-bit integer interfaces will be found.
  35. Imported targets
  36. ^^^^^^^^^^^^^^^^
  37. This module defines the following :prop_tgt:`IMPORTED` targets:
  38. ``BLAS::BLAS``
  39. .. versionadded:: 3.18
  40. The libraries to use for BLAS, if found.
  41. Result Variables
  42. ^^^^^^^^^^^^^^^^
  43. This module defines the following variables:
  44. ``BLAS_FOUND``
  45. library implementing the BLAS interface is found
  46. ``BLAS_LINKER_FLAGS``
  47. uncached list of required linker flags (excluding ``-l`` and ``-L``).
  48. ``BLAS_LIBRARIES``
  49. uncached list of libraries (using full path name) to link against
  50. to use BLAS (may be empty if compiler implicitly links BLAS)
  51. ``BLAS95_LIBRARIES``
  52. uncached list of libraries (using full path name) to link against
  53. to use BLAS95 interface
  54. ``BLAS95_FOUND``
  55. library implementing the BLAS95 interface is found
  56. .. _`BLAS/LAPACK Vendors`:
  57. BLAS/LAPACK Vendors
  58. ^^^^^^^^^^^^^^^^^^^
  59. ``Generic``
  60. Generic reference implementation
  61. ``ACML``, ``ACML_MP``, ``ACML_GPU``
  62. AMD Core Math Library
  63. ``Apple``, ``NAS``
  64. Apple BLAS (Accelerate), and Apple NAS (vecLib)
  65. ``Arm``, ``Arm_mp``, ``Arm_ilp64``, ``Arm_ilp64_mp``
  66. .. versionadded:: 3.18
  67. Arm Performance Libraries
  68. ``ATLAS``
  69. Automatically Tuned Linear Algebra Software
  70. ``CXML``, ``DXML``
  71. Compaq/Digital Extended Math Library
  72. ``EML``, ``EML_mt``
  73. .. versionadded:: 3.20
  74. Elbrus Math Library
  75. ``FLAME``
  76. .. versionadded:: 3.11
  77. BLIS Framework
  78. ``FlexiBLAS``
  79. .. versionadded:: 3.19
  80. ``Fujitsu_SSL2``, ``Fujitsu_SSL2BLAMP``, ``Fujitsu_SSL2SVE``, ``Fujitsu_SSL2BLAMPSVE``
  81. .. versionadded:: 3.20
  82. Fujitsu SSL2 serial and parallel blas/lapack with SVE instructions
  83. ``Goto``
  84. GotoBLAS
  85. ``IBMESSL``, ``IBMESSL_SMP``
  86. IBM Engineering and Scientific Subroutine Library
  87. ``Intel``
  88. Intel MKL 32 bit and 64 bit obsolete versions
  89. ``Intel10_32``
  90. Intel MKL v10 32 bit, threaded code
  91. ``Intel10_64lp``
  92. Intel MKL v10+ 64 bit, threaded code, lp64 model
  93. ``Intel10_64lp_seq``
  94. Intel MKL v10+ 64 bit, sequential code, lp64 model
  95. ``Intel10_64ilp``
  96. .. versionadded:: 3.13
  97. Intel MKL v10+ 64 bit, threaded code, ilp64 model
  98. ``Intel10_64ilp_seq``
  99. .. versionadded:: 3.13
  100. Intel MKL v10+ 64 bit, sequential code, ilp64 model
  101. ``Intel10_64_dyn``
  102. .. versionadded:: 3.17
  103. Intel MKL v10+ 64 bit, single dynamic library
  104. ``NVHPC``
  105. .. versionadded:: 3.21
  106. NVIDIA HPC SDK
  107. ``OpenBLAS``
  108. .. versionadded:: 3.6
  109. ``PhiPACK``
  110. Portable High Performance ANSI C (PHiPAC)
  111. ``SCSL``, ``SCSL_mp``
  112. Scientific Computing Software Library
  113. ``SGIMATH``
  114. SGI Scientific Mathematical Library
  115. ``SunPerf``
  116. Sun Performance Library
  117. .. _`Intel MKL`:
  118. Intel MKL
  119. ^^^^^^^^^
  120. To use the Intel MKL implementation of BLAS, a project must enable at least
  121. one of the ``C`` or ``CXX`` languages. Set ``BLA_VENDOR`` to an Intel MKL
  122. variant either on the command-line as ``-DBLA_VENDOR=Intel10_64lp`` or in
  123. project code:
  124. .. code-block:: cmake
  125. set(BLA_VENDOR Intel10_64lp)
  126. find_package(BLAS)
  127. In order to build a project using Intel MKL, and end user must first
  128. establish an Intel MKL environment:
  129. Intel oneAPI
  130. Source the full Intel environment script:
  131. .. code-block:: shell
  132. . /opt/intel/oneapi/setvars.sh
  133. Or, source the MKL component environment script:
  134. .. code-block:: shell
  135. . /opt/intel/oneapi/mkl/latest/env/vars.sh
  136. Intel Classic
  137. Source the full Intel environment script:
  138. .. code-block:: shell
  139. . /opt/intel/bin/compilervars.sh intel64
  140. Or, source the MKL component environment script:
  141. .. code-block:: shell
  142. . /opt/intel/mkl/bin/mklvars.sh intel64
  143. The above environment scripts set the ``MKLROOT`` environment variable
  144. to the top of the MKL installation. They also add the location of the
  145. runtime libraries to the dynamic library loader environment variable for
  146. your platform (e.g. ``LD_LIBRARY_PATH``). This is necessary for programs
  147. linked against MKL to run.
  148. .. note::
  149. As of Intel oneAPI 2021.2, loading only the MKL component does not
  150. make all of its dependencies available. In particular, the ``iomp5``
  151. library must be available separately, or provided by also loading
  152. the compiler component environment:
  153. .. code-block:: shell
  154. . /opt/intel/oneapi/compiler/latest/env/vars.sh
  155. #]=======================================================================]
  156. # The approach follows that of the ``autoconf`` macro file, ``acx_blas.m4``
  157. # (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
  158. # Check the language being used
  159. if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED))
  160. if(BLAS_FIND_REQUIRED)
  161. message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
  162. else()
  163. message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)")
  164. return()
  165. endif()
  166. endif()
  167. function(_add_blas_target)
  168. if(BLAS_FOUND AND NOT TARGET BLAS::BLAS)
  169. add_library(BLAS::BLAS INTERFACE IMPORTED)
  170. if(BLAS_LIBRARIES)
  171. set_target_properties(BLAS::BLAS PROPERTIES
  172. INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}"
  173. )
  174. endif()
  175. if(BLAS_LINKER_FLAGS)
  176. set_target_properties(BLAS::BLAS PROPERTIES
  177. INTERFACE_LINK_OPTIONS "${BLAS_LINKER_FLAGS}"
  178. )
  179. endif()
  180. endif()
  181. endfunction()
  182. if(CMAKE_Fortran_COMPILER_LOADED)
  183. include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
  184. else()
  185. include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
  186. endif()
  187. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  188. if(BLA_PREFER_PKGCONFIG)
  189. find_package(PkgConfig)
  190. pkg_check_modules(PKGC_BLAS blas)
  191. if(PKGC_BLAS_FOUND)
  192. set(BLAS_FOUND ${PKGC_BLAS_FOUND})
  193. set(BLAS_LIBRARIES "${PKGC_BLAS_LINK_LIBRARIES}")
  194. _add_blas_target()
  195. return()
  196. endif()
  197. endif()
  198. # TODO: move this stuff to a separate module
  199. function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs)
  200. # This function checks for the existence of the combination of libraries
  201. # given by _list. If the combination is found, this checks whether can link
  202. # against that library combination using the name of a routine given by _name
  203. # using the linker flags given by _flags. If the combination of libraries is
  204. # found and passes the link test, ${LIBRARIES} is set to the list of complete
  205. # library paths that have been found. Otherwise, ${LIBRARIES} is set to FALSE.
  206. set(_libraries_work TRUE)
  207. set(_libraries)
  208. set(_combined_name)
  209. if(BLA_STATIC)
  210. if(WIN32)
  211. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
  212. else()
  213. set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  214. endif()
  215. else()
  216. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  217. # for ubuntu's libblas3gf and liblapack3gf packages
  218. set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
  219. endif()
  220. endif()
  221. set(_extaddlibdir "${_addlibdir}")
  222. if(WIN32)
  223. list(APPEND _extaddlibdir ENV LIB)
  224. elseif(APPLE)
  225. list(APPEND _extaddlibdir ENV DYLD_LIBRARY_PATH)
  226. else()
  227. list(APPEND _extaddlibdir ENV LD_LIBRARY_PATH)
  228. endif()
  229. list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
  230. foreach(_library ${_list})
  231. if(_library MATCHES "^-")
  232. # Respect linker flags as-is (required by MKL)
  233. list(APPEND _libraries "${_library}")
  234. else()
  235. string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}")
  236. string(APPEND _combined_name "_${_lib_var}")
  237. if(NOT "${_deps}" STREQUAL "")
  238. string(APPEND _combined_name "_deps")
  239. endif()
  240. if(_libraries_work)
  241. find_library(${_prefix}_${_lib_var}_LIBRARY
  242. NAMES ${_library}
  243. NAMES_PER_DIR
  244. PATHS ${_extaddlibdir}
  245. PATH_SUFFIXES ${_subdirs}
  246. )
  247. mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY)
  248. list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY})
  249. set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY})
  250. endif()
  251. endif()
  252. endforeach()
  253. foreach(_flag ${_flags})
  254. string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}")
  255. string(APPEND _combined_name "_${_flag_var}")
  256. endforeach()
  257. if(_libraries_work)
  258. # Test this combination of libraries.
  259. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_deps})
  260. set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
  261. if(CMAKE_Fortran_COMPILER_LOADED)
  262. check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
  263. else()
  264. check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
  265. endif()
  266. set(CMAKE_REQUIRED_LIBRARIES)
  267. set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
  268. endif()
  269. if(_libraries_work)
  270. if("${_list}" STREQUAL "")
  271. set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
  272. else()
  273. list(APPEND _libraries ${_deps})
  274. endif()
  275. else()
  276. set(_libraries FALSE)
  277. endif()
  278. set(${LIBRARIES} "${_libraries}" PARENT_SCOPE)
  279. endfunction()
  280. set(BLAS_LINKER_FLAGS)
  281. set(BLAS_LIBRARIES)
  282. set(BLAS95_LIBRARIES)
  283. set(_blas_fphsa_req_var BLAS_LIBRARIES)
  284. if(NOT $ENV{BLA_VENDOR} STREQUAL "")
  285. set(BLA_VENDOR $ENV{BLA_VENDOR})
  286. else()
  287. if(NOT BLA_VENDOR)
  288. set(BLA_VENDOR "All")
  289. endif()
  290. endif()
  291. if(NOT BLA_SIZEOF_INTEGER)
  292. # in the reality we do not know which API of BLAS/LAPACK is masked in library
  293. set(_blas_sizeof_integer "ANY")
  294. elseif((BLA_SIZEOF_INTEGER STREQUAL "ANY") OR
  295. (BLA_SIZEOF_INTEGER STREQUAL "4") OR
  296. (BLA_SIZEOF_INTEGER STREQUAL "8"))
  297. set(_blas_sizeof_integer ${BLA_SIZEOF_INTEGER})
  298. else()
  299. message(FATAL_ERROR "BLA_SIZEOF_INTEGER can have only <no value>, ANY, 4, or 8 values")
  300. endif()
  301. # Implicitly linked BLAS libraries?
  302. if(BLA_VENDOR STREQUAL "All")
  303. if(NOT BLAS_LIBRARIES)
  304. check_blas_libraries(
  305. BLAS_LIBRARIES
  306. BLAS
  307. sgemm
  308. ""
  309. ""
  310. ""
  311. ""
  312. ""
  313. )
  314. endif()
  315. if(BLAS_WORKS)
  316. # Give a more helpful "found" message
  317. set(BLAS_WORKS "implicitly linked")
  318. set(_blas_fphsa_req_var BLAS_WORKS)
  319. endif()
  320. endif()
  321. # BLAS in the Intel MKL 10+ library?
  322. if(BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
  323. if(NOT BLAS_LIBRARIES)
  324. if(CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED)
  325. # System-specific settings
  326. if(WIN32)
  327. if(BLA_STATIC)
  328. set(BLAS_mkl_DLL_SUFFIX "")
  329. else()
  330. set(BLAS_mkl_DLL_SUFFIX "_dll")
  331. endif()
  332. else()
  333. if(BLA_STATIC)
  334. set(BLAS_mkl_START_GROUP "-Wl,--start-group")
  335. set(BLAS_mkl_END_GROUP "-Wl,--end-group")
  336. else()
  337. set(BLAS_mkl_START_GROUP "")
  338. set(BLAS_mkl_END_GROUP "")
  339. endif()
  340. # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it)
  341. if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE)
  342. set(BLAS_mkl_INTFACE "gf")
  343. set(BLAS_mkl_THREADING "gnu")
  344. set(BLAS_mkl_OMP "gomp")
  345. else()
  346. set(BLAS_mkl_INTFACE "intel")
  347. set(BLAS_mkl_THREADING "intel")
  348. set(BLAS_mkl_OMP "iomp5")
  349. endif()
  350. set(BLAS_mkl_LM "-lm")
  351. set(BLAS_mkl_LDL "-ldl")
  352. endif()
  353. if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
  354. find_package(Threads)
  355. else()
  356. find_package(Threads REQUIRED)
  357. endif()
  358. if(_blas_sizeof_integer EQUAL 8)
  359. set(BLAS_mkl_ILP_MODE "ilp64")
  360. elseif(_blas_sizeof_integer EQUAL 4)
  361. set(BLAS_mkl_ILP_MODE "lp64")
  362. else()
  363. if(BLA_VENDOR MATCHES "_64ilp")
  364. set(BLAS_mkl_ILP_MODE "ilp64")
  365. else()
  366. set(BLAS_mkl_ILP_MODE "lp64")
  367. endif()
  368. endif()
  369. set(BLAS_SEARCH_LIBS "")
  370. if(BLA_F95)
  371. set(BLAS_mkl_SEARCH_SYMBOL "sgemm_f95")
  372. set(_BLAS_LIBRARIES BLAS95_LIBRARIES)
  373. if(WIN32)
  374. # Find the main file (32-bit or 64-bit)
  375. set(BLAS_SEARCH_LIBS_WIN_MAIN "")
  376. if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  377. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  378. "mkl_blas95${BLAS_mkl_DLL_SUFFIX} mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
  379. endif()
  380. if(BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
  381. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  382. "mkl_blas95_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX} mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
  383. endif()
  384. # Add threading/sequential libs
  385. set(BLAS_SEARCH_LIBS_WIN_THREAD "")
  386. if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
  387. # old version
  388. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  389. "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  390. # mkl >= 10.3
  391. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  392. "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  393. endif()
  394. if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
  395. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  396. "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
  397. endif()
  398. # Cartesian product of the above
  399. foreach(MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
  400. foreach(THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
  401. list(APPEND BLAS_SEARCH_LIBS
  402. "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
  403. endforeach()
  404. endforeach()
  405. else()
  406. if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  407. # old version
  408. list(APPEND BLAS_SEARCH_LIBS
  409. "mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
  410. # mkl >= 10.3
  411. list(APPEND BLAS_SEARCH_LIBS
  412. "${BLAS_mkl_START_GROUP} mkl_blas95 mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
  413. endif()
  414. if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
  415. # old version
  416. list(APPEND BLAS_SEARCH_LIBS
  417. "mkl_blas95 mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
  418. # mkl >= 10.3
  419. list(APPEND BLAS_SEARCH_LIBS
  420. "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
  421. endif()
  422. if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
  423. list(APPEND BLAS_SEARCH_LIBS
  424. "${BLAS_mkl_START_GROUP} mkl_blas95_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}")
  425. endif()
  426. endif()
  427. else()
  428. set(BLAS_mkl_SEARCH_SYMBOL sgemm)
  429. set(_BLAS_LIBRARIES BLAS_LIBRARIES)
  430. if(WIN32)
  431. # Find the main file (32-bit or 64-bit)
  432. set(BLAS_SEARCH_LIBS_WIN_MAIN "")
  433. if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  434. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  435. "mkl_intel_c${BLAS_mkl_DLL_SUFFIX}")
  436. endif()
  437. if(BLA_VENDOR MATCHES "^Intel10_64i?lp" OR BLA_VENDOR STREQUAL "All")
  438. list(APPEND BLAS_SEARCH_LIBS_WIN_MAIN
  439. "mkl_intel_${BLAS_mkl_ILP_MODE}${BLAS_mkl_DLL_SUFFIX}")
  440. endif()
  441. # Add threading/sequential libs
  442. set(BLAS_SEARCH_LIBS_WIN_THREAD "")
  443. if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  444. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  445. "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  446. endif()
  447. if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
  448. # old version
  449. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  450. "libguide40 mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  451. # mkl >= 10.3
  452. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  453. "libiomp5md mkl_intel_thread${BLAS_mkl_DLL_SUFFIX}")
  454. endif()
  455. if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
  456. list(APPEND BLAS_SEARCH_LIBS_WIN_THREAD
  457. "mkl_sequential${BLAS_mkl_DLL_SUFFIX}")
  458. endif()
  459. # Cartesian product of the above
  460. foreach(MAIN ${BLAS_SEARCH_LIBS_WIN_MAIN})
  461. foreach(THREAD ${BLAS_SEARCH_LIBS_WIN_THREAD})
  462. list(APPEND BLAS_SEARCH_LIBS
  463. "${MAIN} ${THREAD} mkl_core${BLAS_mkl_DLL_SUFFIX}")
  464. endforeach()
  465. endforeach()
  466. else()
  467. if(BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
  468. # old version
  469. list(APPEND BLAS_SEARCH_LIBS
  470. "mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
  471. # mkl >= 10.3
  472. list(APPEND BLAS_SEARCH_LIBS
  473. "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
  474. endif()
  475. if(BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR STREQUAL "All")
  476. # old version
  477. list(APPEND BLAS_SEARCH_LIBS
  478. "mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core guide")
  479. # mkl >= 10.3
  480. list(APPEND BLAS_SEARCH_LIBS
  481. "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_${BLAS_mkl_THREADING}_thread mkl_core ${BLAS_mkl_END_GROUP} ${BLAS_mkl_OMP}")
  482. endif()
  483. if(BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$" OR BLA_VENDOR STREQUAL "All")
  484. list(APPEND BLAS_SEARCH_LIBS
  485. "${BLAS_mkl_START_GROUP} mkl_${BLAS_mkl_INTFACE}_${BLAS_mkl_ILP_MODE} mkl_sequential mkl_core ${BLAS_mkl_END_GROUP}")
  486. endif()
  487. #older versions of intel mkl libs
  488. if(BLA_VENDOR STREQUAL "Intel" OR BLA_VENDOR STREQUAL "All")
  489. list(APPEND BLAS_SEARCH_LIBS
  490. "mkl")
  491. list(APPEND BLAS_SEARCH_LIBS
  492. "mkl_ia32")
  493. list(APPEND BLAS_SEARCH_LIBS
  494. "mkl_em64t")
  495. endif()
  496. endif()
  497. endif()
  498. if(BLA_VENDOR MATCHES "^Intel10_64_dyn$" OR BLA_VENDOR STREQUAL "All")
  499. # mkl >= 10.3 with single dynamic library
  500. list(APPEND BLAS_SEARCH_LIBS
  501. "mkl_rt")
  502. endif()
  503. # MKL uses a multitude of partially platform-specific subdirectories:
  504. if(BLA_VENDOR STREQUAL "Intel10_32")
  505. set(BLAS_mkl_ARCH_NAME "ia32")
  506. else()
  507. set(BLAS_mkl_ARCH_NAME "intel64")
  508. endif()
  509. if(WIN32)
  510. set(BLAS_mkl_OS_NAME "win")
  511. elseif(APPLE)
  512. set(BLAS_mkl_OS_NAME "mac")
  513. else()
  514. set(BLAS_mkl_OS_NAME "lin")
  515. endif()
  516. if(DEFINED ENV{MKLROOT})
  517. file(TO_CMAKE_PATH "$ENV{MKLROOT}" BLAS_mkl_MKLROOT)
  518. # If MKLROOT points to the subdirectory 'mkl', use the parent directory instead
  519. # so we can better detect other relevant libraries in 'compiler' or 'tbb':
  520. get_filename_component(BLAS_mkl_MKLROOT_LAST_DIR "${BLAS_mkl_MKLROOT}" NAME)
  521. if(BLAS_mkl_MKLROOT_LAST_DIR STREQUAL "mkl")
  522. get_filename_component(BLAS_mkl_MKLROOT "${BLAS_mkl_MKLROOT}" DIRECTORY)
  523. endif()
  524. endif()
  525. set(BLAS_mkl_LIB_PATH_SUFFIXES
  526. "compiler/lib" "compiler/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}"
  527. "compiler/lib/${BLAS_mkl_ARCH_NAME}"
  528. "mkl/lib" "mkl/lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}"
  529. "mkl/lib/${BLAS_mkl_ARCH_NAME}"
  530. "lib" "lib/${BLAS_mkl_ARCH_NAME}_${BLAS_mkl_OS_NAME}"
  531. "lib/${BLAS_mkl_ARCH_NAME}"
  532. )
  533. foreach(_search ${BLAS_SEARCH_LIBS})
  534. string(REPLACE " " ";" _search ${_search})
  535. if(NOT ${_BLAS_LIBRARIES})
  536. check_blas_libraries(
  537. ${_BLAS_LIBRARIES}
  538. BLAS
  539. ${BLAS_mkl_SEARCH_SYMBOL}
  540. ""
  541. "${_search}"
  542. "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}"
  543. "${BLAS_mkl_MKLROOT}"
  544. "${BLAS_mkl_LIB_PATH_SUFFIXES}"
  545. )
  546. endif()
  547. endforeach()
  548. unset(_search)
  549. unset(BLAS_mkl_ILP_MODE)
  550. unset(BLAS_mkl_INTFACE)
  551. unset(BLAS_mkl_THREADING)
  552. unset(BLAS_mkl_OMP)
  553. unset(BLAS_mkl_DLL_SUFFIX)
  554. unset(BLAS_mkl_LM)
  555. unset(BLAS_mkl_LDL)
  556. unset(BLAS_mkl_MKLROOT)
  557. unset(BLAS_mkl_MKLROOT_LAST_DIR)
  558. unset(BLAS_mkl_ARCH_NAME)
  559. unset(BLAS_mkl_OS_NAME)
  560. unset(BLAS_mkl_LIB_PATH_SUFFIXES)
  561. endif()
  562. endif()
  563. endif()
  564. if(BLA_F95)
  565. find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS95_LIBRARIES)
  566. set(BLAS95_FOUND ${BLAS_FOUND})
  567. if(BLAS_FOUND)
  568. set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
  569. endif()
  570. endif()
  571. # gotoblas? (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
  572. if(BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
  573. if(NOT BLAS_LIBRARIES)
  574. check_blas_libraries(
  575. BLAS_LIBRARIES
  576. BLAS
  577. sgemm
  578. ""
  579. "goto2"
  580. ""
  581. ""
  582. ""
  583. )
  584. endif()
  585. endif()
  586. # FlexiBLAS? (http://www.mpi-magdeburg.mpg.de/mpcsc/software/FlexiBLAS/)
  587. if(BLA_VENDOR STREQUAL "FlexiBLAS" OR BLA_VENDOR STREQUAL "All")
  588. set(_blas_flexiblas_lib "flexiblas")
  589. if(_blas_sizeof_integer EQUAL 8)
  590. string(APPEND _blas_flexiblas_lib "64")
  591. endif()
  592. if(NOT BLAS_LIBRARIES)
  593. check_blas_libraries(
  594. BLAS_LIBRARIES
  595. BLAS
  596. sgemm
  597. ""
  598. "${_blas_flexiblas_lib}"
  599. ""
  600. ""
  601. ""
  602. )
  603. endif()
  604. unset(_blas_flexiblas_lib)
  605. endif()
  606. # OpenBLAS? (http://www.openblas.net)
  607. if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
  608. set(_blas_openblas_lib "openblas")
  609. if(_blas_sizeof_integer EQUAL 8)
  610. string(APPEND _blas_openblas_lib "64")
  611. endif()
  612. if(NOT BLAS_LIBRARIES)
  613. check_blas_libraries(
  614. BLAS_LIBRARIES
  615. BLAS
  616. sgemm
  617. ""
  618. "${_blas_openblas_lib}"
  619. ""
  620. ""
  621. ""
  622. )
  623. endif()
  624. if(NOT BLAS_LIBRARIES AND (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED))
  625. if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
  626. find_package(Threads)
  627. else()
  628. find_package(Threads REQUIRED)
  629. endif()
  630. set(_threadlibs "${CMAKE_THREAD_LIBS_INIT}")
  631. if(BLA_STATIC)
  632. if (CMAKE_C_COMPILER_LOADED)
  633. find_package(OpenMP COMPONENTS C)
  634. list(PREPEND _threadlibs "${OpenMP_C_LIBRARIES}")
  635. elseif(CMAKE_CXX_COMPILER_LOADED)
  636. find_package(OpenMP COMPONENTS CXX)
  637. list(PREPEND _threadlibs "${OpenMP_CXX_LIBRARIES}")
  638. endif()
  639. endif()
  640. check_blas_libraries(
  641. BLAS_LIBRARIES
  642. BLAS
  643. sgemm
  644. ""
  645. "${_blas_openblas_lib}"
  646. "${_threadlibs}"
  647. ""
  648. ""
  649. )
  650. unset(_threadlibs)
  651. endif()
  652. unset(_blas_openblas_lib)
  653. endif()
  654. # ArmPL blas library? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries)
  655. if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All")
  656. # Check for 64bit Integer support
  657. if(_blas_sizeof_integer EQUAL 8)
  658. set(_blas_armpl_lib "armpl_ilp64")
  659. elseif(_blas_sizeof_integer EQUAL 4)
  660. set(_blas_armpl_lib "armpl_lp64")
  661. else()
  662. if(BLA_VENDOR MATCHES "_ilp64")
  663. set(_blas_armpl_lib "armpl_ilp64")
  664. else()
  665. set(_blas_armpl_lib "armpl_lp64")
  666. endif()
  667. endif()
  668. # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp
  669. if(BLA_VENDOR MATCHES "_mp")
  670. string(APPEND _blas_armpl_lib "_mp")
  671. endif()
  672. if(NOT BLAS_LIBRARIES)
  673. check_blas_libraries(
  674. BLAS_LIBRARIES
  675. BLAS
  676. sgemm
  677. ""
  678. "${_blas_armpl_lib}"
  679. ""
  680. ""
  681. ""
  682. )
  683. endif()
  684. unset(_blas_armpl_lib)
  685. endif()
  686. # FLAME's blis library? (https://github.com/flame/blis)
  687. if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")
  688. set(_blas_flame_lib "blis")
  689. if(_blas_sizeof_integer EQUAL 8)
  690. string(APPEND _blas_flame_lib "64")
  691. endif()
  692. if(NOT BLAS_LIBRARIES)
  693. check_blas_libraries(
  694. BLAS_LIBRARIES
  695. BLAS
  696. sgemm
  697. ""
  698. "${_blas_flame_lib}"
  699. ""
  700. ""
  701. ""
  702. )
  703. endif()
  704. unset(_blas_flame_lib)
  705. endif()
  706. # BLAS in the ATLAS library? (http://math-atlas.sourceforge.net/)
  707. if(BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
  708. if(NOT BLAS_LIBRARIES)
  709. check_blas_libraries(
  710. BLAS_LIBRARIES
  711. BLAS
  712. dgemm
  713. ""
  714. "blas;f77blas;atlas"
  715. ""
  716. ""
  717. ""
  718. )
  719. endif()
  720. endif()
  721. # BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
  722. if(BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
  723. if(NOT BLAS_LIBRARIES)
  724. check_blas_libraries(
  725. BLAS_LIBRARIES
  726. BLAS
  727. sgemm
  728. ""
  729. "sgemm;dgemm;blas"
  730. ""
  731. ""
  732. ""
  733. )
  734. endif()
  735. endif()
  736. # BLAS in Alpha CXML library?
  737. if(BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
  738. if(_blas_sizeof_integer EQUAL 8)
  739. if(BLA_VENDOR STREQUAL "CXML")
  740. message(FATAL_ERROR "CXML does not support Int64 type")
  741. endif()
  742. else()
  743. if(NOT BLAS_LIBRARIES)
  744. check_blas_libraries(
  745. BLAS_LIBRARIES
  746. BLAS
  747. sgemm
  748. ""
  749. "cxml"
  750. ""
  751. ""
  752. ""
  753. )
  754. endif()
  755. endif()
  756. endif()
  757. # BLAS in Alpha DXML library? (now called CXML, see above)
  758. if(BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
  759. if(_blas_sizeof_integer EQUAL 8)
  760. if(BLA_VENDOR STREQUAL "DXML")
  761. message(FATAL_ERROR "DXML does not support Int64 type")
  762. endif()
  763. else()
  764. if(NOT BLAS_LIBRARIES)
  765. check_blas_libraries(
  766. BLAS_LIBRARIES
  767. BLAS
  768. sgemm
  769. ""
  770. "dxml"
  771. ""
  772. ""
  773. ""
  774. )
  775. endif()
  776. endif()
  777. endif()
  778. # BLAS in Sun Performance library?
  779. if(BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
  780. if(NOT BLAS_LIBRARIES)
  781. check_blas_libraries(
  782. BLAS_LIBRARIES
  783. BLAS
  784. sgemm
  785. "-xlic_lib=sunperf"
  786. "sunperf;sunmath"
  787. ""
  788. ""
  789. ""
  790. )
  791. if(BLAS_LIBRARIES)
  792. set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
  793. endif()
  794. endif()
  795. endif()
  796. # BLAS in SCSL library? (SGI/Cray Scientific Library)
  797. if(BLA_VENDOR MATCHES "SCSL" OR BLA_VENDOR STREQUAL "All")
  798. set(_blas_scsl_lib "scs")
  799. if(_blas_sizeof_integer EQUAL 8)
  800. string(APPEND _blas_scsl_lib "_i8")
  801. endif()
  802. if(BLA_VENDOR MATCHES "_mp")
  803. string(APPEND _blas_scsl_lib "_mp")
  804. endif()
  805. if(NOT BLAS_LIBRARIES)
  806. check_blas_libraries(
  807. BLAS_LIBRARIES
  808. BLAS
  809. sgemm
  810. ""
  811. "${_blas_scsl_lib}"
  812. ""
  813. ""
  814. ""
  815. )
  816. endif()
  817. unset(_blas_scsl_lib)
  818. endif()
  819. # BLAS in SGIMATH library?
  820. if(BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
  821. if(NOT BLAS_LIBRARIES)
  822. check_blas_libraries(
  823. BLAS_LIBRARIES
  824. BLAS
  825. sgemm
  826. ""
  827. "complib.sgimath"
  828. ""
  829. ""
  830. ""
  831. )
  832. endif()
  833. endif()
  834. # BLAS in IBM ESSL library?
  835. if(BLA_VENDOR MATCHES "IBMESSL" OR BLA_VENDOR STREQUAL "All")
  836. set(_blas_essl_lib "essl")
  837. if(BLA_VENDOR MATCHES "_SMP")
  838. string(APPEND _blas_essl_lib "smp")
  839. endif()
  840. if(_blas_sizeof_integer EQUAL 8)
  841. string(APPEND _blas_essl_lib "6464")
  842. endif()
  843. if(NOT BLAS_LIBRARIES)
  844. check_blas_libraries(
  845. BLAS_LIBRARIES
  846. BLAS
  847. sgemm
  848. ""
  849. "${_blas_essl_lib}"
  850. ""
  851. ""
  852. ""
  853. )
  854. endif()
  855. unset(_blas_essl_lib)
  856. endif()
  857. # BLAS in acml library?
  858. if(BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
  859. if(((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
  860. ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
  861. ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
  862. )
  863. # try to find acml in "standard" paths
  864. if(WIN32)
  865. file(GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt")
  866. else()
  867. file(GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt")
  868. endif()
  869. if(WIN32)
  870. file(GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples")
  871. else()
  872. file(GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples")
  873. endif()
  874. list(GET _ACML_ROOT 0 _ACML_ROOT)
  875. list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
  876. if(_ACML_ROOT)
  877. get_filename_component(_ACML_ROOT ${_ACML_ROOT} PATH)
  878. if(_blas_sizeof_integer EQUAL 8)
  879. set(_ACML_PATH_SUFFIX "_int64")
  880. else()
  881. set(_ACML_PATH_SUFFIX "")
  882. endif()
  883. if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
  884. set(_ACML_COMPILER32 "ifort32")
  885. set(_ACML_COMPILER64 "ifort64")
  886. elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
  887. # 32-bit not supported
  888. set(_ACML_COMPILER64 "ifx")
  889. elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro")
  890. set(_ACML_COMPILER32 "sun32")
  891. set(_ACML_COMPILER64 "sun64")
  892. elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
  893. set(_ACML_COMPILER32 "pgi32")
  894. if(WIN32)
  895. set(_ACML_COMPILER64 "win64")
  896. else()
  897. set(_ACML_COMPILER64 "pgi64")
  898. endif()
  899. elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Open64")
  900. # 32 bit builds not supported on Open64 but for code simplicity
  901. # We'll just use the same directory twice
  902. set(_ACML_COMPILER32 "open64_64")
  903. set(_ACML_COMPILER64 "open64_64")
  904. elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG")
  905. set(_ACML_COMPILER32 "nag32")
  906. set(_ACML_COMPILER64 "nag64")
  907. else()
  908. set(_ACML_COMPILER32 "gfortran32")
  909. set(_ACML_COMPILER64 "gfortran64")
  910. endif()
  911. if(BLA_VENDOR STREQUAL "ACML_MP")
  912. set(_ACML_MP_LIB_DIRS
  913. "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
  914. "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib")
  915. else()
  916. set(_ACML_LIB_DIRS
  917. "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
  918. "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib")
  919. endif()
  920. endif()
  921. elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
  922. set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
  923. endif()
  924. if(BLA_VENDOR STREQUAL "ACML_MP")
  925. foreach(BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS})
  926. check_blas_libraries(
  927. BLAS_LIBRARIES
  928. BLAS
  929. sgemm
  930. "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} ""
  931. )
  932. if(BLAS_LIBRARIES)
  933. break()
  934. endif()
  935. endforeach()
  936. elseif(BLA_VENDOR STREQUAL "ACML_GPU")
  937. foreach(BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS})
  938. check_blas_libraries(
  939. BLAS_LIBRARIES
  940. BLAS
  941. sgemm
  942. "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} ""
  943. )
  944. if(BLAS_LIBRARIES)
  945. break()
  946. endif()
  947. endforeach()
  948. else()
  949. foreach(BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS})
  950. check_blas_libraries(
  951. BLAS_LIBRARIES
  952. BLAS
  953. sgemm
  954. "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} ""
  955. )
  956. if(BLAS_LIBRARIES)
  957. break()
  958. endif()
  959. endforeach()
  960. endif()
  961. # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
  962. if(NOT BLAS_LIBRARIES)
  963. check_blas_libraries(
  964. BLAS_LIBRARIES
  965. BLAS
  966. sgemm
  967. ""
  968. "acml;acml_mv"
  969. ""
  970. ""
  971. ""
  972. )
  973. endif()
  974. if(NOT BLAS_LIBRARIES)
  975. check_blas_libraries(
  976. BLAS_LIBRARIES
  977. BLAS
  978. sgemm
  979. ""
  980. "acml_mp;acml_mv"
  981. ""
  982. ""
  983. ""
  984. )
  985. endif()
  986. if(NOT BLAS_LIBRARIES)
  987. check_blas_libraries(
  988. BLAS_LIBRARIES
  989. BLAS
  990. sgemm
  991. ""
  992. "acml;acml_mv;CALBLAS"
  993. ""
  994. ""
  995. ""
  996. )
  997. endif()
  998. endif() # ACML
  999. # Apple BLAS library?
  1000. if(BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
  1001. if(_blas_sizeof_integer EQUAL 8)
  1002. if(BLA_VENDOR STREQUAL "Apple")
  1003. message(FATAL_ERROR "Accelerate Framework does not support Int64 type")
  1004. endif()
  1005. else()
  1006. if(NOT BLAS_LIBRARIES)
  1007. check_blas_libraries(
  1008. BLAS_LIBRARIES
  1009. BLAS
  1010. dgemm
  1011. ""
  1012. "Accelerate"
  1013. ""
  1014. ""
  1015. ""
  1016. )
  1017. endif()
  1018. endif()
  1019. endif()
  1020. # Apple NAS (vecLib) library?
  1021. if(BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
  1022. if(_blas_sizeof_integer EQUAL 8)
  1023. if(BLA_VENDOR STREQUAL "NAS")
  1024. message(FATAL_ERROR "Accelerate Framework does not support Int64 type")
  1025. endif()
  1026. else()
  1027. if(NOT BLAS_LIBRARIES)
  1028. check_blas_libraries(
  1029. BLAS_LIBRARIES
  1030. BLAS
  1031. dgemm
  1032. ""
  1033. "vecLib"
  1034. ""
  1035. ""
  1036. ""
  1037. )
  1038. endif()
  1039. endif()
  1040. endif()
  1041. # Elbrus Math Library?
  1042. if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All")
  1043. set(_blas_eml_lib "eml")
  1044. if(_blas_sizeof_integer EQUAL 8)
  1045. string(APPEND _blas_eml_lib "_ilp64")
  1046. endif()
  1047. # Check for OpenMP support, VIA BLA_VENDOR of eml_mt
  1048. if(BLA_VENDOR MATCHES "_mt")
  1049. string(APPEND _blas_eml_lib "_mt")
  1050. endif()
  1051. if(NOT BLAS_LIBRARIES)
  1052. check_blas_libraries(
  1053. BLAS_LIBRARIES
  1054. BLAS
  1055. sgemm
  1056. ""
  1057. "${_blas_eml_lib}"
  1058. ""
  1059. ""
  1060. ""
  1061. )
  1062. endif()
  1063. unset(_blas_eml_lib)
  1064. endif()
  1065. # Fujitsu SSL2 Library?
  1066. if(NOT BLAS_LIBRARIES
  1067. AND (BLA_VENDOR MATCHES "^Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All"))
  1068. set(_blas_fjlapack_lib "fjlapack")
  1069. set(_blas_fjlapack_flags "-Kopenmp")
  1070. if(BLA_VENDOR MATCHES "BLAMP")
  1071. string(APPEND _blas_fjlapack_lib "ex")
  1072. endif()
  1073. if(BLA_VENDOR MATCHES "SVE")
  1074. string(APPEND _blas_fjlapack_lib "sve")
  1075. endif()
  1076. if(_blas_sizeof_integer EQUAL 8)
  1077. string(APPEND _blas_fjlapack_lib "_ilp64")
  1078. endif()
  1079. if(NOT BLAS_LIBRARIES)
  1080. check_blas_libraries(
  1081. BLAS_LIBRARIES
  1082. BLAS
  1083. sgemm
  1084. "${_blas_fjlapack_flags}"
  1085. "${_blas_fjlapack_lib}"
  1086. ""
  1087. ""
  1088. ""
  1089. )
  1090. if(BLAS_LIBRARIES)
  1091. set(BLAS_LINKER_FLAGS ${_blas_fjlapack_flags})
  1092. endif()
  1093. endif()
  1094. unset(_blas_fjlapack_flags)
  1095. unset(_blas_fjlapack_lib)
  1096. endif()
  1097. # BLAS in nVidia HPC SDK? (https://developer.nvidia.com/hpc-sdk)
  1098. if(BLA_VENDOR STREQUAL "NVHPC" OR BLA_VENDOR STREQUAL "All")
  1099. set(_blas_nvhpc_lib "blas")
  1100. if(_blas_sizeof_integer EQUAL 8)
  1101. string(APPEND _blas_nvhpc_lib "_ilp64")
  1102. elseif(_blas_sizeof_integer EQUAL 4)
  1103. string(APPEND _blas_nvhpc_lib "_lp64")
  1104. endif()
  1105. if(NOT BLAS_LIBRARIES)
  1106. check_blas_libraries(
  1107. BLAS_LIBRARIES
  1108. BLAS
  1109. sgemm
  1110. ""
  1111. "${_blas_nvhpc_lib}"
  1112. ""
  1113. ""
  1114. ""
  1115. )
  1116. endif()
  1117. # an additional check for NVHPC 2020
  1118. # which does not have differentiation
  1119. # between lp64 and ilp64 modes
  1120. if(NOT BLAS_LIBRARIES AND NOT _blas_sizeof_integer EQUAL 8)
  1121. set(_blas_nvhpc_lib "blas")
  1122. check_blas_libraries(
  1123. BLAS_LIBRARIES
  1124. BLAS
  1125. sgemm
  1126. ""
  1127. "${_blas_nvhpc_lib}"
  1128. ""
  1129. ""
  1130. ""
  1131. )
  1132. endif()
  1133. unset(_blas_nvhpc_lib)
  1134. endif()
  1135. # Generic BLAS library?
  1136. if(BLA_VENDOR STREQUAL "Generic" OR
  1137. BLA_VENDOR STREQUAL "All")
  1138. set(_blas_generic_lib "blas")
  1139. if(_blas_sizeof_integer EQUAL 8)
  1140. string(APPEND _blas_generic_lib "64")
  1141. endif()
  1142. if(NOT BLAS_LIBRARIES)
  1143. check_blas_libraries(
  1144. BLAS_LIBRARIES
  1145. BLAS
  1146. sgemm
  1147. ""
  1148. "${_blas_generic_lib}"
  1149. ""
  1150. ""
  1151. ""
  1152. )
  1153. endif()
  1154. unset(_blas_generic_lib)
  1155. endif()
  1156. # On compilers that implicitly link BLAS (i.e. CrayPrgEnv) we used a
  1157. # placeholder for empty BLAS_LIBRARIES to get through our logic above.
  1158. if(BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES")
  1159. set(BLAS_LIBRARIES "")
  1160. endif()
  1161. if(NOT BLA_F95)
  1162. find_package_handle_standard_args(BLAS REQUIRED_VARS ${_blas_fphsa_req_var})
  1163. endif()
  1164. _add_blas_target()
  1165. unset(_blas_fphsa_req_var)
  1166. unset(_blas_sizeof_integer)
  1167. unset(_BLAS_LIBRARIES)