Basic Tensor Algebra Subroutines (BTAS) is a C++ library for tensor algebra. BTAS is a reference implementation of Tensor Working Group concept spec. The library can be optionally used header-only at the cost of much lower performance for most operations.
- C++17 compiler
- CMake
- Boost C++ libraries
- (required) Container, Iterator, Random
- (optional) Serialization for serialization (non-header-only)
- (used by default, strongly recommended, but can be disabled) BLAS+LAPACK libraries and their BLAS++/LAPACK++ C++ APIs for optimized operations (non-header-only)
TL;DR version
cmake -S /path/to/BTAS/srcdir -B /path/to/BTAS/builddir -DCMAKE_PREFIX_PATH="/path/to/boost;/path/to/blas/and/lapack"
- optional:
cmake --build /path/to/BTAS/builddir --target check
- if configured with
-DBTAS_BUILD_DEPS_FROM_SOURCE=ON
:cmake --build /path/to/BTAS/builddir --target build-boost-in-BTAS
cmake --build /path/to/BTAS/builddir --target install
- Linear algebra (BLAS+LAPACK): should come with your dev toolchain (e.g., on MacOS) or can be installed using the system package manager or as a vendor-provided package (e.g., Intel Math Kernel Libraries)
- Boost:
- It is recommended to use a package manager to install Boost. This can be doneas follows:
- APT package manager (e.g., on Ubuntu Linux):
apt-get install libboost-all-dev
- Homebrew package manager (on MacOS) via
brew install boost
.
- APT package manager (e.g., on Ubuntu Linux):
- You can also try to build Boost yourself by following instructions here.
- Last resort is to let BTAS build Boost from source, as a CMake subproject using FetchContent. Unfortunately, Boost's emerging CMake harness used to build it is not yet fully functional, hence may not be as robust as desired. Here are some ints:
- Configure with CMake cache variable
BTAS_BUILD_DEPS_FROM_SOURCE
toON
(either via command line or theccmake
GUI) - If BTAS is the top-level CMake project (i.e. it is not being built as a subproject itself) installing BTAS by building its install target may not build Boost libraries automatically. Thus the user may need to build
build-boost-in-BTAS
target manually before buildinginstall
target.
- Configure with CMake cache variable
- It is recommended to use a package manager to install Boost. This can be doneas follows:
CMAKE_CXX_COMPILER
-- specifies the C++ compiler (by default CMake will look for the C++ compiler inPATH
)CMAKE_INSTALL_PREFIX
-- specifies the installation prefix (by default CMake will install to/usr/local
)CMAKE_BUILD_TYPE
-- specifies the build type (by default CMake will build inRelease
mode)CMAKE_PREFIX_PATH
-- semicolon-separated list of paths specifying the locations of dependenciesBTAS_USE_BLAS_LAPACK
-- specifies whether to enable the use of BLAS/LAPACK via the BLAS++/LAPACK++ APIs; the default isON
BTAS_BUILD_DEPS_FROM_SOURCE
-- specifies whether to enable building the missing dependencies (Boost) from source; the default isOFF
BUILD_TESTING
-- specifies whether to build unit tests; the default isON
TARGET_MAX_INDEX_RANK
-- specifies the rank for which the default BTAS index type will use stack; the default is6