Tweak integer detection logic to use ilaver #171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the current integer detection logic, we first try the
isamax()function if it exists, and if it doesn't (like if we only have a LAPACK library), we trydpotrfwith an invalid input.The problem is,
dpotrfwith an invalid input can trigger thexerbla()error reporting function, which in the reference BLAS/LAPACK will print an error to the screen and stop the program. (see JuliaLinearAlgebra/BLISBLAS.jl#24 for a case where we see this "in the wild").Instead, lets use the
ilaver()function in LAPACK as the first test to see what the integer size is. This test is similar to the others, where it takes a pointer to an integer that it then writes. We use this to see if it treats those pointers as 32-bits or 64-bits internally by making it-1before the call (so all bits are 1), and then seeing if the upper 32-bits are written to in the call (e.g., if the value is still negative). If this test can't be done (e.g., there is noilaver()function), or it fails for some reason, we fallback to the current tests in the same order as they are now.cc @ViralBShah, @amontoison, @giordano, @staticfloat
I ran this on a bunch of BLAS/LAPACK libraries available on Fedora, and here are the results: