diff --git a/INSTALL.md b/INSTALL.md index e49c773409..0de83b3761 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -40,7 +40,7 @@ Both methods are supported. However, for most users we _strongly_ recommend to b - Boost.Container: header-only - Boost.Test: header-only or (optionally) as a compiled library, *only used for unit testing* - Boost.Range: header-only, *only used for unit testing* -- [BTAS](https://github.com/ValeevGroup/BTAS), tag 0dc805fd7f2dea5e56eff94ab1c44b2b2397edd7 . If usable BTAS installation is not found, TiledArray will download and compile +- [BTAS](https://github.com/ValeevGroup/BTAS), tag 8ac131460e05e9470779880e15acc5642a451e7a . If usable BTAS installation is not found, TiledArray will download and compile BTAS from source. *This is the recommended way to compile BTAS for all users*. - [MADNESS](https://github.com/m-a-d-n-e-s-s/madness), tag 51f0615f094bca5110ea149100e39c0edb25a4f2 . Only the MADworld runtime and BLAS/LAPACK C API component of MADNESS is used by TiledArray. @@ -275,13 +275,22 @@ algebra in TA: BLAS++/LAPACK++ during the TA configuration. There are 2 mechanisms by which BLAS++/LAPACK++ discover BLAS/LAPACK: - _the built-in custom discovery kit_; no options exist to provide any control - - standard CMake BLAS/LAPACK modules. + - standard CMake [BLAS](https://cmake.org/cmake/help/latest/module/FindBLAS.html)/[LAPACK](https://cmake.org/cmake/help/latest/module/FindLAPACK.html) modules. The latter is used if CMake cache variable `BLA_VENDOR` is specified: - `BLA_VENDOR` -- controls which vendor BLAS/LAPACK library will be sought - (see [CMake docs](https://cmake.org/cmake/help/latest/module/FindLAPACK.html)); - by default all possible vendor libraries will be considered. E.g., to force the use of the Accelerate - framework on MacOS use `-DBLA_VENDOR=Apple`. + (see [CMake docs](https://cmake.org/cmake/help/latest/module/FindLAPACK.html)); + by default all possible vendor libraries will be considered. E.g., to force the use of the Accelerate + framework on MacOS use `-DBLA_VENDOR=Apple`. + + Unfortunately, if the standard CMake modules discover BLAS/LAPACK, + BLAS++/LAPACK++ will not attempt to discover their name mangling convention. + To specify the name mangling to be assumed by BLAS++/LAPACK++ specify CMake cache variable `LINALG_MANGLING`: + - `LINALG_MANGLING` -- specifies the name mangling assumed by BLAS++/LAPACK++ + when using BLAS/LAPACK. Valid values are: + - `lower`: function/variable `dgemm` will be mangled to `dgemm`, + - `UPPER`: function/variable `dgemm` will be mangled to `DGEMM`, + - `lower_`: function/variable `dgemm` will be mangled to `dgemm_` (default). More information can be found in the installation instructions for [BLAS++](https://icl.bitbucket.io/blaspp/md__i_n_s_t_a_l_l.html) and diff --git a/cmake/modules/FindOrFetchBTAS.cmake b/cmake/modules/FindOrFetchBTAS.cmake index 9abf776279..775d1964b6 100644 --- a/cmake/modules/FindOrFetchBTAS.cmake +++ b/cmake/modules/FindOrFetchBTAS.cmake @@ -10,9 +10,16 @@ endif (NOT TARGET BTAS::BTAS) # if not found, build via FetchContent if (NOT TARGET BTAS::BTAS) + # BTAS will load BLAS++/LAPACK++ ... if those use CMake's FindBLAS/FindLAPACK (as indicated by defined BLA_VENDOR) + # will need to specify Fortran linkage convention ... manually for now, switching to NWX's linear algebra discovery + # is necessary to handle all the corner cases for automatic discovery + if (DEFINED BLA_VENDOR) + set(_linalgpp_use_standard_linalg_kits TRUE) + endif(DEFINED BLA_VENDOR) + if (NOT TILEDARRAY_HAS_CUDA) # tell BLAS++/LAPACK++ to ignore CUDA - set(use_cuda FALSE CACHE BOOL "Whether to look for CUDA-enabled libs in BLAS++/LAPACK++") + set(gpu_backend none CACHE STRING "The device backend to use for Linalg++") endif() include(FetchContent) @@ -35,6 +42,26 @@ if (NOT TARGET BTAS::BTAS) # set BTAS_CONFIG to the install location so that we know where to find it set(BTAS_CONFIG ${CMAKE_INSTALL_PREFIX}/${BTAS_INSTALL_CMAKEDIR}/btas-config.cmake) + # define macros specifying Fortran mangling convention, if necessary + if (_linalgpp_use_standard_linalg_kits) + if (NOT TARGET blaspp AND NOT TARGET lapackpp) + message(FATAL_ERROR "blaspp or lapackpp targets missing") + endif(NOT TARGET blaspp AND NOT TARGET lapackpp) + if (LINALG_MANGLING STREQUAL lower) + target_compile_definitions(blaspp PUBLIC -DBLAS_FORTRAN_LOWER=1) + target_compile_definitions(lapackpp PUBLIC -DLAPACK_FORTRAN_LOWER=1) + elseif(LINALG_MANGLING STREQUAL UPPER OR LINALG_MANGLING STREQUAL upper) + target_compile_definitions(blaspp PUBLIC -DBLAS_FORTRAN_UPPER=1) + target_compile_definitions(lapackpp PUBLIC -DLAPACK_FORTRAN_UPPER=1) + else() + if (NOT LINALG_MANGLING STREQUAL lower_) + message(WARNING "Linear algebra libraries' mangling convention not specified; specify -DLINALG_MANGLING={lower,lower_,UPPER}, if needed; will assume lower_") + endif(NOT LINALG_MANGLING STREQUAL lower_) + target_compile_definitions(blaspp PUBLIC -DBLAS_FORTRAN_ADD_=1) + target_compile_definitions(lapackpp PUBLIC -DLAPACK_FORTRAN_ADD_=1) + endif() + endif (_linalgpp_use_standard_linalg_kits) + endif(NOT TARGET BTAS::BTAS) # postcond check diff --git a/external/versions.cmake b/external/versions.cmake index 414e3cafa7..3d3b478e5e 100644 --- a/external/versions.cmake +++ b/external/versions.cmake @@ -24,8 +24,8 @@ set(TA_TRACKED_MADNESS_PREVIOUS_TAG 34ef8e6d6c61098d44ca559a530b4096e40b9a01) set(TA_TRACKED_MADNESS_VERSION 0.10.1) set(TA_TRACKED_MADNESS_PREVIOUS_VERSION 0.10.1) -set(TA_TRACKED_BTAS_TAG 0dc805fd7f2dea5e56eff94ab1c44b2b2397edd7) -set(TA_TRACKED_BTAS_PREVIOUS_TAG b7bddfcef89612652878854a447bacf4d3f6a5b0) +set(TA_TRACKED_BTAS_TAG 8ac131460e05e9470779880e15acc5642a451e7a ) +set(TA_TRACKED_BTAS_PREVIOUS_TAG 0dc805fd7f2dea5e56eff94ab1c44b2b2397edd7) set(TA_TRACKED_CUTT_TAG 0e8685bf82910bc7435835f846e88f1b39f47f09) set(TA_TRACKED_CUTT_PREVIOUS_TAG 592198b93c93b7ca79e7900b9a9f2e79f9dafec3)