Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for BLAS Syrk #1358

Open
tzachar opened this issue Feb 6, 2024 · 6 comments
Open

Add support for BLAS Syrk #1358

tzachar opened this issue Feb 6, 2024 · 6 comments

Comments

@tzachar
Copy link

tzachar commented Feb 6, 2024

Hi.

Thank you guys for this awesome library.

In my application, I need to compute a gram matrix (basically, x.t().dot(x)).
Using gemm is wasteful, as the result is symmetric and the lower half is redundant, so using syrk in this case is twice as fast as gemm.

On a general note, it would be really useful if the library could also easily support calling any general BLAS / LAPACK function using appropriate idioms (like getting memory layout, strides, etc.)

@nilgoyette
Copy link
Collaborator

This has already been discussed in this issue.

You probably already know but general_mat_mul is "hidden" in linalg module. However this only offers gemm, which is not what you're asking for.

@tzachar
Copy link
Author

tzachar commented Feb 7, 2024

I am aware of general_mat_mul.
Did anyone ever end up writing an additional crate for BLAS over ndarray?

@tzachar tzachar changed the title Add support for BLAS SYMM Add support for LAPACK Syrk Feb 7, 2024
@tzachar tzachar changed the title Add support for LAPACK Syrk Add support for BLAS Syrk Feb 7, 2024
@nilgoyette
Copy link
Collaborator

Afaik, nobody did. And I don't think anyone will do it in the near future. ndarray hasn't evolved much in the last 4-5 years because of a lack of maintainers.

@Pencilcaseman
Copy link

I'd be interested in improving the BLAS functionality. Having spent a lot of time messing around with multidimensional array libraries myself (sole developer of LibRapid), I've got a decent understanding of how best to implement things.

As an experiment, I wrote a BLAS wrapper for Rust, which wraps a system BLAS library in a C API, which is further wrapped in a Rust API. It supports any BLAS library that has a CBLAS interface.

Implementing something like this (or using this directly??) could be interesting. Is that something worth looking into?

On an unrelated note, I'd also be interested in getting OpenCL and CUDA support added to this library -- an obvious first step would be BLAS with CLBlast and cuBLAS, but JIT-compiled kernels could be interesting, too.

@nilgoyette
Copy link
Collaborator

This is something that @bluss might be interested in.

@ajz34
Copy link

ajz34 commented Jul 14, 2024

Hi devs,
I found this issue when I'm working on some code to wrap BLAS (https://github.com/ajz34/blas-array2) recently. This crate is mostly for our own project (may not even useful due to our hesitation on using ndarray), but is probably something you may be interested in.
This crate can be seen as a proof-of-existence for Rust to implement Fortran95-interface-like API (https://netlib.org/blas/blast-forum/chapter2.pdf). It's more rust-like than C-FFI-like.
blas-array2 acts as a wrapper and can handle SYRK (and other BLAS2/3 subroutines) with matrix defined by ndarray, but not a solution built as member function in ndarray (by comparasion, .dot function in numpy can detect whether SYRK could be utilized).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants