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 BLAS C bindings #37

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Add BLAS C bindings #37

wants to merge 7 commits into from

Conversation

cbeuw
Copy link

@cbeuw cbeuw commented May 10, 2023

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

@sarah-quinones
Copy link
Owner

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

@cbeuw
Copy link
Author

cbeuw commented May 13, 2023

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

@sevagh
Copy link

sevagh commented Jan 11, 2024

@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

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

Successfully merging this pull request may close these issues.

3 participants