faer-rs
faer-rs copied to clipboard
Add BLAS C bindings
Add BLAS API C FFI bindings so that (eventually) faer can be used as a drop-in replacement to BLAS libraries in software like NumPy
hi! thanks for the pr.
i like the idea of having a blas api, although i'm not sure if i have all of it implemented in faer so far. how much of the api do you want to cover in this PR? it's fine if you don't do all of it since we can incrementally build it up until it's finished
Hi, I agree that I shouldn't try to get 100% BLAS coverage in this PR. I'll do the basic abstractions and get a couple functions working with LD_PRELOAD
before I mark the PR ready. There are some annoying bits like different function names for the 64-bit version and Fortran ABI (AFAIK for the purpose of BLAS this is compatible with C ABI, but I need to look into this more)
I saw you said on reddit that you're not planning to add LAPACK APIs, though I don't think a full coverage is necessary. We only need to add the ones faer performs really well in and users can benefit from it with LD_PRELOAD
@cbeuw btw, I was able to use this PR as a BLAS library in a C++ project (only sgemm/sgemv, a small subset, but a real usecase nonetheless). It uses Eigen (which enables -DEIGEN_USE_BLAS
to use a fortran BLAS api).
If you need testers or anything to help this PR, I'd be happy to help!
My opinion on the CBLAS vs. BLAS Fortran API is that exposing both would be valuable.
Many libraries expect the BLAS fortran API (despite the implementations being written in C), for example I added the following macros to implement sgemm_
and sgemv_
(the fortran APIs) to be identical to cblas_sgemm
and cblas_sgemv
: https://github.com/sevagh/faer-rs/commit/605a94715c09ecf14a611b882449922d211c8309#diff-10b85327a1b6cc7d4e5b6710ad870d56a7c855d6e964a5d7e57c45cb5f565bceR81
Note that my fork was just to quickly hack on your PR, I don't intend on interfering with your contribution