Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Source of BLAS and LAPACK via OpenBLAS

License

NotificationsYou must be signed in to change notification settings

blas-lapack-rs/openblas-src

Repository files navigation

The package provides a source ofBLAS andLAPACK viaOpenBLAS.

Configuration

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.

Dependencies

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 to1andOpenBLAS 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.

Caching

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.

Windows and vcpkg

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-msvctoolchain, 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.

ENV variables

Proxy

Theopenblas-src crate will detect and use proxy settings from your environmentvariables, such ashttp_proxy andhttps_proxy to download necessary dependencies.

Build System through OpenBLAS

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 variableopenblas-src variable
TARGETOPENBLAS_TARGET
CCOPENBLAS_CC
FCOPENBLAS_FC
HOSTCCOPENBLAS_HOSTCC
RANLIBOPENBLAS_RANLIB

Cross-compile

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--targetwill be used.

Rust targetOpenBLAS target
aarch64ARMV8
armARMV6
armv5teARMV5
armv6ARMV6
armv7ARMV7
loongarch64LOONGSONGENERIC
mips64MIPS64_GENERIC
mips64elMIPS64_GENERIC
riscv64RISCV64_GENERIC
cskyCK860FV
sparcSPARCV7

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.

Contribution

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

Stars

Watchers

Forks

Contributors20

Languages


[8]ページ先頭

©2009-2025 Movatter.jp