-
Notifications
You must be signed in to change notification settings - Fork 370
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
BLIS should allow simultaneously exporting both 32- and 64-bit variants of BLAS/CBLAS #43
Comments
Has also been an issue in Matlab where they use the ILP64 MKL, if you try to link a mex file against system LP64 BLAS, for many years before Julia ever existed. ILP64 BLAS only ever worked in Julia if you didn't try to load any other binary applications compiled against system LP64 BLAS. It was fragile until we implemented the renaming. Lots of context in JuliaLang/julia#4923 OpenMathLib/OpenBLAS#646 OpenMathLib/OpenBLAS#459 JuliaLang/julia#8734. We just append |
Is it possible to support dynamic dispatch, wherein both |
@tkelman Why doesn't Julia just call CBLAS? I thought support for that was pretty broad, at least in contexts where Julia is used. |
We do in a handful of places where the Fortran calling convention differs between gfortran and MKL/Accelerate. I don't think cblas typically supports 64 bit indices - I could be wrong though. |
@jeffhammond: That would indeed be cool, but unfortunately I don't think there's any way to make that happen given the vagaries of different platforms' linking models... |
@tkelman Does CBLAS need to support 64b integers to meet Julia's needs? For BLAS1 operations, it is trivial to chunk if there are more than 2B elements in a vector. Given the memory constrains, if one has a matrix dimension larger than 2B, the BLAS2/3 operations are going to perform like BLAS1 operations and thus chunking shouldn't be a big issue. @njsmith How many different conventions need to be supported for the feature to have high value to the user community? |
It was easier for us to rename the symbols than add chunking around every single blas and lapack call. When openblas is built with ILP64 indices, its cblas also gets built with 64 bit integers afaict, but that's a non default setting and will cause segfaults if you're not careful about symbol names and loading other blas libraries in the same process. |
@tkelman Eww, that's terrible of OpenBLAS. They should always use C |
They should also always use 32 bit ints for the fortran interface by that reasoning. The problems in practice are identical. |
I think that the use cases that matter in practice are:
For the last case I'm not sure if anyone ever needs If we combine the two compatible 64-bit options, this gives us a total of 3 configurations that are important to test/support:
In principle BLIS certainly could retain the flexibility to support other configurations -- like 32-bit integers internally on 64-bit systems, or 64-bit BLIS + 32-bit |
@jeffhammond: The above list does assume that for your "modern fortran codes" use case, you don't actually care about |
I completely agree with @njsmith's summary there. There's the question of what to do on CBLAS as well. In the OpenBLAS scenario as used by Julia, we have a handful of CBLAS symbols that we use (just |
Edited my comment to speak more explicitly about CBLAS -- specifically, I think |
Oh, ugh, except I missed that Julia's 64-bit cblas functions are named like |
It's not "wrong" per se, just a consequence of how we implemented it. We apply a suffix uniformly to all symbols in the library, after the gfortran mangling rather than before. Looks funny, but just easier to deal with. |
Jeez, sorry about the spam, my phone is stupid |
@tkelman: I guess by "wrong" i mean "if we were writing a standard from scratch this is obviously not what we would do". Since now we are talking about making a standard and BLIS implementing it, there's a question about whether we should follow the dorky existing thing, or fix the existing thing and then implement that :-). I guess you're voting for following the existing thing? |
"add a suffix, but before the trailing underscore for symbols that are pretending to be from fortran" (or "add |
I'm not seeing much consensus here. If someone wants to "create a standard" then we can try to implement it. |
The de facto standard is that the standard BLAS/CBLAS functions take 32-bit integers in their API. Julia experimented with changing this so that they could use 64-bit integers in their main BLAS wrappers, and this worked great for a little while until they discovered that when people started trying to link in other existing BLAS-using code, this code was assuming that BLAS uses 32-bit integers and was causing segfaults. Their solution was to continue to use a 64-bit integer version of BLAS, but with symbols renamed to avoid collisions (so e.g.
dgemm_
uses 32-bit integers, anddgemm_64_
uses 64-bit integers... [edited to get the 64-bit symbol names correct])As mentioned in #37 (comment) , it would be great if a single BLIS library could export both 32- and 64-bit versions of these symbols simultaneously. It doesn't look like this would be too hard, since both the BLAS2BLIS interface is already generated using C preprocessor magic, and the CBLAS wrapper is already getting programmatically patched...
The text was updated successfully, but these errors were encountered: