Skip to content

Add low-level wrappers for BLAS and LAPACK #1386

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

amontoison
Copy link
Collaborator

@amontoison amontoison commented Jun 19, 2025

@ViralBShah I was at the Householder Symposium last week and had a discussion with Julien Langou (@langou), the main maintainer of reference-LAPACK, about what we’re doing in Julia for BLAS / LAPACK and our nice LBT feature.

Some feedback I got is that Julien doesn’t understand why we don’t expose all the arguments of the BLAS / LAPACK routines, and why we took the liberty of fusing om* / un* routines but not sy* / he*.

What I concluded with Julien is that we should maybe expose the low-level wrappers directly and call them from our higher-level interfaces.
This would make it easier to update with new releases and would also give users the ability to reuse buffers, which is currently a significant limitation of our API.
I also think it would help Julien interact more easily with us.
He’s starting to get interested in using Julia for unit testing reference-LAPACK and teaching!

A few months ago, I wrote a script to generate wrappers for Fortran routines implemented in F77 (for HSL), and I was able to adapt it for BLAS / LAPACK.
It is similar to what we obtain with Clang.jl from the C header files.
I open the PR as a draft for now to get feedback.

@ViralBShah
Copy link
Member

ViralBShah commented Jun 19, 2025

This is something I have always wanted to do myself as well.

Is there a noticeable impact on system image size?

@ViralBShah
Copy link
Member

It would be great if this PR could be a branch on this repo (easier to work on than a fork). Possibly needs these fixes:

diff --git a/src/blas.jl b/src/blas.jl
index 15c6467..3ebe212 100644
--- a/src/blas.jl
+++ b/src/blas.jl
@@ -1417,7 +1417,7 @@ Return the updated `C`.
 """
 function gemmt! end
 
-for (gemmt, elty) in
+for (fname, elty) in
         ((:dgemmt,:Float64),
          (:sgemmt,:Float32),
          (:zgemmt,:ComplexF64),
@@ -1488,7 +1488,7 @@ Update `C` as `alpha*A*B + beta*C` or the other three variants according to
 """
 function gemm! end
 
-for (gemm, elty) in
+for (fname, elty) in
         ((:dgemm,:Float64),
          (:sgemm,:Float32),
          (:zgemm,:ComplexF64),
@@ -1595,9 +1595,9 @@ for (mfname, elty) in ((:dsymm,:Float64),
             chkstride1(A)
             chkstride1(B)
             chkstride1(C)
-            $fname(side, uplo, m, n,
-                   alpha, A, max(1,stride(A,2)), B,
-                   max(1,stride(B,2)), beta, C, max(1,stride(C,2)))
+            $mfname(side, uplo, m, n,
+                    alpha, A, max(1,stride(A,2)), B,
+                    max(1,stride(B,2)), beta, C, max(1,stride(C,2)))
             C
         end
         function symm(side::AbstractChar, uplo::AbstractChar, alpha::($elty), A::AbstractMatrix{$elty}, B::AbstractMatrix{$elty})

@amontoison
Copy link
Collaborator Author

I wanted to create a branch but it seems that I don't have the rights on this repo.
It is why I did a fork.

Thanks for the patch, I also need to find how to use @blasfunc with a @ccall.

@ViralBShah
Copy link
Member

I didn't realize you don't have access. Just invited.

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.

2 participants