hasty

Crates.iohasty
lib.rshasty
version0.2.5
sourcesrc
created_at2023-12-02 01:25:33.834085
updated_at2024-03-30 04:59:58.085174
descriptionA Rust interface to system BLAS libraries for fast linear algebra operations
homepage
repositoryhttps://github.com/Pencilcaseman/hasty
max_upload_size
id1055799
size6,551,546
Toby Davis (Pencilcaseman)

documentation

README

Hasty Logo

Crates.io Documentation License Continuous Integration

Hasty

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.

Example

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);
}

Development Plans

More BLAS Libraries

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.

Fall-back BLAS Library

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.

Missing Functions

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!

Commit count: 52

cargo fmt