-
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
Match default integer sizes to standard interfaces #42
Match default integer sizes to standard interfaces #42
Conversation
These two changes both match my understanding of the de facto standards here too. |
I think blis/frame/include/bli_config_macro_defs.h Line 158 in 2dc5c0a
|
Github refused to accept my comment via the web interface so I will try
again via email...
Lots of Fortran applications compile with `-i8` or its equivalent, meaning
that they cause the default `INTEGER` to be 64b. The Fortran interface
needs to be flexible and allow the user to build with either 32b or 64b
integers.
|
@jeffhammond: Sure, the argument isn't that BLIS should only support 32-bits, but rather that the BLIS defaults (and the "public API", i.e. the API used in widely-distributed shared library builds) should match the fortran defaults. |
@tkelman No, that's just not true. MKL plays just fine with apps as long as users link against the correct library - LP64 or ILP64. $ ls -1 /opt/intel/mkl/lib/*lp*
/opt/intel/mkl/lib/libmkl_blas95_ilp64.a
/opt/intel/mkl/lib/libmkl_blas95_lp64.a
/opt/intel/mkl/lib/libmkl_intel_ilp64.a
/opt/intel/mkl/lib/libmkl_intel_ilp64.dylib
/opt/intel/mkl/lib/libmkl_intel_lp64.a
/opt/intel/mkl/lib/libmkl_intel_lp64.dylib
/opt/intel/mkl/lib/libmkl_lapack95_ilp64.a
/opt/intel/mkl/lib/libmkl_lapack95_lp64.a |
@jeffhammond not if your application (edit: distributed as a binary) tries to load an LP64 |
@njsmith Sorry, but there is no truly default Fortran integer size. Fortran does not have an ABI like C does. There is a default integer type ( The real solution is for Fortran users to call C symbols with Fortran 2003 The ideal solution would be for BLIS to support the standard |
We're essentially proposing doing that work here, just have to start with selecting a default. The argument is that for 32 bit and 64 bit Fortran binary interfaces to coexist in a world where libraries get distributed as binaries, one of them needs a different name. |
@tkelman Matlab is capable of calling MKL properly. If users are writing broken MEX code, that's their problem. It sucks that Fortran isn't like C, e.g. does not have an ABI. You should consider WG5 to change this. Until then, please try not to break user experience for thousands of quantum chemists who have arrays with more than a billion elements in them. |
@tkelman Just give them both a descriptive name. Put 32 in one and 64 in the other. Why do you have to pick a default and remove the bitwidth from that one? |
If we could go back and time this would be a great solution but... making Note that e.g. Debian and Ubuntu have a standard ABI for all the BLAS packages they ship, which allows users to pick which BLAS they want to use at runtime. This ABI uses symbols named like |
So, the primary reason I'm suggesting the change to f77_int is because it matches the netlib cblas and f77 blas headers. The default expectation for BLAS integers is already established there. A BLAS with better chosen indices and a 64 bit compatible interface would be great, but it's better to have something that conforms to the already standard ABI. |
The user experience is probably already broken if those quantum chemists' applications happen to load numpy into the same address space. Maybe every HPC center has a custom ILP64 build of numpy or only ever uses MKL, but I'll defer to @njsmith on whether he's come across that kind of situation (or whether ILP64 MKL is likely to work with numpy at all? I believe the commercial numpy distributions all use LP64 BLAS). |
@tkelman: well, because python doesn't use RTLD_GLOBAL we are less prone to symbol clashes than Julia, but the underlying issues still exist... I'm not sure whether numpy supports 64-bit BLAS at all (no reason it couldn't, but such libraries are extremely rare in the wild, so it may never have been wedged into the giant nest of |
@insertinterestingnamehere: @tkelman is right though that your patch needs to also change the default value of |
Well, it's a library maintainer's problem for anyone writing a library that calls BLAS and might be used in an environment where ILP64 BLAS happens to be loaded in the same process. You get libraries that work fine outside of Matlab / pre-symbol-renaming Julia /
I'm actually not so sure whether Julia is using |
@njsmith You're right, However, it would be useful to have a build without @tkelman Major quantum chemistry packages do not use Numpy - they use Fortran :-) I suspect that a quantum chemist who used Numpy would be so productive that they would not have to bother with the Fortran packages with the legacy cruft that motivated my comments in the first place. |
52ea54f
to
127d14c
Compare
@njsmith Yes, I wrote and now maintain the Cython API in SciPy. Identifying the correct BLAS library, dealing with the different name mangling conventions, and patching any bugs (see scipy/scipy#4105) are all massive barriers for someone who is trying to build a small-ish Python extension. That makes platform independent code hard to find and hard to write. For distribulting modules it is vastly easier for everyone to load the BLAS and LAPACK routines they need via capsules in Cython's cimport mechanisms. |
I've updated this to fix the two places where BLIS_BLAS2BLIS_INT_TYPE_SIZE may have been set to 64. AFAICT, that's all that is needed. |
@@ -152,10 +152,10 @@ | |||
// leading dimensions (ie: column strides) within the BLAS compatibility layer. | |||
// A value of 32 results in the compatibility layer using 32-bit signed integers | |||
// while 64 results in 64-bit integers. Any other value results in use of the | |||
// C99 type "long int". Note that this ONLY affects integers used within the | |||
// C99 type "size_t". Note that this ONLY affects integers used within the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is discussing the BLAS layer so I'm pretty sure you mean int
, not size_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yes. I'll make that change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
127d14c
to
b88a16a
Compare
Sorry, it looks like a bunch of my edits to the Windows build system got rolled in to this. I'll pull that out as well. |
@insertintetestingnamehere: did you mean to include a bunch of py3 changes to the windows build dir here? (NB also that it's not clear the windows build dir is useful -- for Windows build we've just been using the regular build system with a mingw cross-compiler, and if #13 is fixed then we should be able to use the regular build system with msys2 for native builds.) |
standard cblas interface more closely.
b88a16a
to
8e7eb4c
Compare
@njsmith no, that was the result of habitual use of |
typedef signed long int gint_t; | ||
typedef unsigned long int guint_t; | ||
typedef ptrdiff_t gint_t; | ||
typedef size_t guint_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could use intptr_t
and uintptr_t
here, and remove the need for stddef.h
? Otherwise looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to use size_t
and ptrdiff_t
because they accurately describe the fact that these pointers will be used to address things within a single object. Unfortunately, there are some architectures weird enough that size_t
is not always the same as uintptr_t
(http://stackoverflow.com/a/14068191/1935144). There's also the fact that MSVC 2008 doesn't have a stdint.h
by default, so, if/when we have a build system capable of using msvc 2008 for the reference kernels, we'd be stuck providing platform specific definitions for these integers to provide sensible default behavior.
It seemed simpler to rely on stddef.h
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the stdint.h
dependency is a problem, given that BLIS uses stdint.h
typedefs pervasively (e.g., 2 lines above this one). And I'm not sure that anyone will ever care about MSVC 2008 anyway -- for those who need MSVC 2008 ABI compatibility, there's mingwpy, and mingwpy isn't restricted to the reference kernels. As for segmented architectures, I guess anyone trying to ported BLIS to one of those should specify a BLIS_INT_TYPE_SIZE
instead of hoping that this fallback code will somehow do something intelligent :-).
But sure, this is fundamentally just a matter of taste and doesn't matter too much. Maybe @fgvanzee will clarify which way he prefers :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's certainly a matter of preference. Whichever version the maintainers prefer is fine with me.
At this point in time, the default BLAS integer size is 32-bit and the default internal integer size is 64-bit if NB: The third branch in the |
This matches the default integers to
size_t
andptrdiff_t
so that they match the size of a pointer even on LLP64 platforms like Windows.I also went ahead and changed the default
f77_int
definition from long to int to more closely match the Fortran and C blas interfaces. Though, to my knowledge, it's not standardized anywhere, Fortran compilers usually use 32 bit integers by default.I'm in the process of testing this myself. Putting this here for discussion for now.