WIP: DOC: write a contributor guide page about using BLAS/LAPACK#21130
WIP: DOC: write a contributor guide page about using BLAS/LAPACK#21130rgommers wants to merge 1 commit into
Conversation
tylerjereddy
left a comment
There was a problem hiding this comment.
This looks very useful/excellent start. I added only minor proofreading things, and learned a fair bit reading through. This is certainly quite complex, I imagine there may be some discussion.
| a common symbol prefix and/or suffix. Examples: | ||
|
|
||
| - ``scipy-openblas`` always uses a ``scipy_`` symbol prefix. | ||
| - The ILP64 OpenBLAS builds use a ``64_`` symbol suffix (typically;it's |
| - ``scipy-openblas`` always uses a ``scipy_`` symbol prefix. | ||
| - The ILP64 OpenBLAS builds use a ``64_`` symbol suffix (typically;it's | ||
| also possible that there is no suffix). | ||
| - Accelerate uses a ``$NEWLAPACK`` suffix for LP64 symbols, and ``$NEWLAPACK_ILP64`` for ILP64 symbols. |
There was a problem hiding this comment.
Interesting, is the $ explicit/raw, or meant to be substituted like a variable? That's a weird one!
There was a problem hiding this comment.
It's an actual raw $ as part of the symbol name.
| also possible that there is no suffix). | ||
| - Accelerate uses a ``$NEWLAPACK`` suffix for LP64 symbols, and ``$NEWLAPACK_ILP64`` for ILP64 symbols. | ||
|
|
||
| Finally, there's is compiler mangling. Most commonly used Fortran compilers |
There was a problem hiding this comment.
there's is -> there is
|
This is indeed great and much needed. Thank you for this. |
| ``build/scipy/linalg/_lapack_subroutines.h`` with ``C_INT`` instead of | ||
| ``int``... | ||
| - call the functions as ``BLAS_FUNC(name)``, where ``name`` is the canonical | ||
| name for the BLAS or LAPACK function (e.g., ``daxpy``) |
There was a problem hiding this comment.
What seems to work today is
$ git diff HEAD^
diff --git a/scipy/interpolate/meson.build b/scipy/interpolate/meson.build
index 4c3631c0e1..25973a0846 100644
--- a/scipy/interpolate/meson.build
+++ b/scipy/interpolate/meson.build
@@ -123,8 +123,7 @@ py3.extension_module('_rgi_cython',
__fitpack_lib = static_library('__fitpack',
['src/__fitpack.h', 'src/__fitpack.cc'],
- dependencies:[lapack]
+ dependencies:[lapack, np_dep, py3_dep]
)
__fitpack_dep = declare_dependency(
diff --git a/scipy/interpolate/src/__fitpack.h b/scipy/interpolate/src/__fitpack.h
index 471eca55a8..6f71adb7a2 100644
--- a/scipy/interpolate/src/__fitpack.h
+++ b/scipy/interpolate/src/__fitpack.h
@@ -2,9 +2,11 @@
#include <iostream>
#include <tuple>
#include <vector>
+
+#include "../_build_utils/src/npy_cblas.h"
#include "../_build_utils/src/fortran_defs.h"
-#define DLARTG F_FUNC(dlartg, DLARTG)
+#define DLARTG BLAS_FUNC(dlartg)
It'd be great indeed to generate the header file so that it can be included --- unless the dance for telling meson to use a generated header is less than this (which I'm not sure about TBH).
|
Recently, we added code using two ways of declaring LAPACK prototypes from C/C++ :
Both ways pass CI, both our regular runs and wheel builds. Ralf pointed out offline that 1. possibly works because the SciPy build process constructs name mangled wrappers already, via https://github.com/scipy/scipy/blob/main/scipy/_build_utils/_generate_blas_wrapper.py and https://github.com/scipy/scipy/blob/main/scipy/_build_utils/meson.build#L12 So does it mean we don't need to redo mangling manually and 1. is the right way forward? |
|
Solution (2) should be the right thing to use. I'm pretty sure that (1) is not robust. Fortran compiler mangling results are compiler-dependent, so the trailing underscore in
Note that we do this if and only if there's a symbol prefix or suffix used (so for |
|
Problem I encountered with (2) is that not all symbols are available (#21314). So that gives me the impression that the list is maintained and not generated. I would prefer a solution, if possible at all, that we create some intermediate layer that separates compiler issues from the symbol names. That is to say from the application layer all LAPACK consuming routines see a single standard (with or without underscore, or usage like (2) etc. it doesn't matter what the standard is) and we handle the symbols at a central place potentially investigating the names and generating some runtime macros, somehow take care of it in one place. I still don't have a good grip on where things happen or which tool is leaking symbols of (1) or (2) but when you are back in action let's have an offline session together with Evgeni if you folks are up to it. |
+1. We had an offline discussion that there's a header file autogenerated at some build stage, and maybe the right thing is to just commit it to the repository instead. That would be my preferred solution, too.
Definitely let's! |
|
xref gh-22743 for some relevant discussion and updates to support ILP64. |
Closes gh-20002.