Crates.io | hasty |
lib.rs | hasty |
version | 0.2.5 |
source | src |
created_at | 2023-12-02 01:25:33.834085 |
updated_at | 2024-03-30 04:59:58.085174 |
description | A Rust interface to system BLAS libraries for fast linear algebra operations |
homepage | |
repository | https://github.com/Pencilcaseman/hasty |
max_upload_size | |
id | 1055799 |
size | 6,551,546 |
Hasty provides a Rust-native interface to high-performance BLAS libraries, such as OpenBLAS, Intel MKL, Apple Accelerate, and more.
Unlike existing BLAS bindings, Hasty will automatically detect and link to the best available
BLAS library on your system without any configuration required. You can also specify a path to
a specific BLAS library via the HASTY_BLAS_PATH
environment variable, if you wish.
Note that you may need to perform a clean build of your project if you change the BLAS library that Hasty links to.
For more information, see the documentation.
fn main() {
let lib = hasty::get_blas_library();
println!("Using BLAS Library: {lib}");
type Scalar = f32;
let m: u64 = 2;
let n: u64 = 1;
let k: u64 = 3;
let mut a: Vec<Scalar> = vec![0.0; (m * k) as usize];
let mut b: Vec<Scalar> = vec![0.0; (k * n) as usize];
let mut c: Vec<Scalar> = vec![0.0; (m * n) as usize];
for i in 0..(m * k) {
a[i as usize] = i as Scalar + 1.0;
}
for i in 0..(k * n) {
b[i as usize] = i as Scalar + 1.0;
}
hasty::level3::gemm(
hasty::StorageOrder::RowMajor,
hasty::Transpose::NoTrans,
hasty::Transpose::NoTrans,
m,
n,
k,
1.0,
&a,
k,
&b,
n,
0.0,
&mut c,
n,
);
println!("Result: {:?}", c);
}
Hasty currently supports a range of BLAS libraries, but it's difficult to test them all. We want to support as many BLAS libraries as possible, so if you find a configuration that doesn't work, please open an issue.
We aim to have fall-back implementations for all BLAS functions if we don't find a suitable BLAS library on your system, but they will be much slower than the optimized implementations provided by BLAS libraries. Ideally, we'd like to optimise these implementations as much as possible, but that's a tricky task and will require contributions from the community.
Hasty is still a work in progress, and there are a lot of BLAS functions to implement. If you need a function that isn't implemented yet, please open an issue or submit a pull request, and I'll get it added as soon as possible!