- Notifications
You must be signed in to change notification settings - Fork49
Source of BLAS and LAPACK via OpenBLAS
License
blas-lapack-rs/openblas-src
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The package provides a source ofBLAS andLAPACK viaOpenBLAS.
The following Cargo features are supported:
cache
to build in a shared directory instead oftarget
(see below),cblas
to build CBLAS (enabled by default),lapacke
to build LAPACKE (enabled by default),static
to link to OpenBLAS statically,system
to skip building the bundled OpenBLAS.
Note: On Windows, OpenBLAS can not be built from source. Thesystem
feature issupposed to be used.
If you want to build OpenBLAS from source, you need to have the following dependenciesinstalled:
- HOSTCC compiler (e.g.,
gcc
,clang
, oricc
), make
,- CC compiler of the target architecture (e.g.,
aarch64-linux-gnu-gcc
foraarch64
), - Fortran compiler of the target architecture(e.g.,
gfortran
,flang
, orifort
),if there is no Fortran compiler detected, the flagNOFORTRAN
should be set to1
andOpenBLAS
will only compile BLAS and f2c-converted LAPACK. For more information,please refer to theUse f2c translations of LAPACK when no Fortran compiler is available.
Thecache
feature allows the OpenBLAS build products to be reused betweencrates that have differenttarget
directories. This avoids rebuilding OpenBLASunnecessarily. However, this also preventscargo clean
from working properly,since the aforementioned build products will not be removed by the command.
The OpenBLAS binary will be placed at${XDG_DATA_HOME}/openblas_build/[hash of build configure object]
. For example, build with LAPACK and build withoutLAPACK will be placed on different directories. If you build OpenBLAS as ashared library, you need to add the above directory toLD_LIBRARY_PATH
(forLinux) orDYLD_LIBRARY_PATH
(for macOS). Since build from source is notsupported on Windows (see next section), this feature is also not supported.
On Windows,openblas-src
relies onvcpkg to find OpenBLAS. Before building,you must have the correct OpenBLAS installed for your target triplet and kind oflinking. For instance, to link dynamically for thex86_64-pc-windows-msvc
toolchain, installopenblas
for thex64-windows
triplet:
vcpkg install openblas --triplet x64-windows
To link OpenBLAS statically, installopenblas
for thex64-windows-static-md
triplet:
vcpkg install openblas --triplet x64-windows-static-md
To link OpenBLAS and C Runtime (CRT) statically, installopenblas
for thex64-windows-static
triplet:
vcpkg install openblas --triplet x64-windows-static
and build with+crt-static
option
RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-pc-windows-msvc
Please see the"Static and dynamic C runtimes" in The Rust reference for detail.
Theopenblas-src
crate will detect and use proxy settings from your environmentvariables, such ashttp_proxy
andhttps_proxy
to download necessary dependencies.
According to theOpenbLAS build system, the variables used by OpenBLAS could bepassed through environment, such asDYNAMIC_LIST
,NUM_THREADS
.
HOWEVER, for some of the variables, theopenblas-src
crate rename them toothers to avoid conflicts with the existing envs. The following is the list ofthe variables that are renamed:
OpenBLAS variable | openblas-src variable |
---|---|
TARGET | OPENBLAS_TARGET |
CC | OPENBLAS_CC |
FC | OPENBLAS_FC |
HOSTCC | OPENBLAS_HOSTCC |
RANLIB | OPENBLAS_RANLIB |
Apart from providing the--target
option tocargo build
, one also has tospecify thecross-compilation variables of OpenBLAS.They can be set as environment variables forcargo build
using theOPENBLAS_
prefix as follows:OPENBLAS_CC
,OPENBLAS_FC
,OPENBLAS_HOSTCC
, andOPENBLAS_TARGET
.
If you do not set these variables, theopenblas-build
will try to detect them.
ForOPENBLAS_TARGET
, the basic target that corresponds to the arch of--target
will be used.
Rust target | OpenBLAS target |
---|---|
aarch64 | ARMV8 |
arm | ARMV6 |
armv5te | ARMV5 |
armv6 | ARMV6 |
armv7 | ARMV7 |
loongarch64 | LOONGSONGENERIC |
mips64 | MIPS64_GENERIC |
mips64el | MIPS64_GENERIC |
riscv64 | RISCV64_GENERIC |
csky | CK860FV |
sparc | SPARCV7 |
ForOPENBLAS_CC
andOPENBLAS_HOSTCC
, thecc
crate will be used to detectthe compiler. Please refer to thecc documentationfor more information.
ForOPENBLAS_FC
,openblas-build
will try to detect the compiler through theOPENBLAS_CC
set above. It will replace thegcc
withgfortran
,clang
withflang
, andicc
withifort
and then test if the Fortran compiler exists.
Note: If there is no Fortran compiler detected, the build flagNOFORTRAN
willbe set to1
andOpenBLAS
will only compile BLAS and f2c-converted LAPACK.For more information, please refer to theUse f2c translations of LAPACK when no Fortran compiler is available.
Your contribution is highly appreciated. Do not hesitate to open an issue or apull request. Note that any contribution submitted for inclusion in the projectwill be licensed according to the terms given inLICENSE.md.
About
Source of BLAS and LAPACK via OpenBLAS
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.