MAINT: Further fixups to uint alignment checks #12706
Merged
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.
Backport of #12677.
A few more fixes following on #12626, based on testing on a ppc64be system.
First, on this system some einsum tests failed due typo in that PR: ; should have been &&. This wasn't caught by x64 unit tests, so I've added a test that should cover those code paths.
Second, I figured out that some of the fix in #12626 wasn't quite right: I had misunderstood what the NPY_ITER_ALIGNED flag is supposed to do. My understanding now is that is a request to guarantee that the nditer buffers are "true" aligned. (uint alignment is only an internal numpy thing which users shouldn't know about), which nditer it does by forcing a buffer/cast if that flag is requested, since all new buffers are true aligned. With that understanding, it now seems that the NPY_OP_ITFLAG_ALIGNED flag is not needed: Its only use was as a precalculated computation of the aligned parameter of PyArray_GetDTypeTransferFunction, but that is more safely computed on the spot, based on both uint and true alignment of the op. So I've removed all uses of NPY_OP_ITFLAG_ALIGNED.
This latter change was indirectly discovered from staring at the code while trying to bug-hunt failed alignment asserts on ppc64be. But those turned out to be irrelevant glibc problems from #10491. At least it got me to read a lot of code over more thoroughly: I also made sure that the ufunc code doesn't need alignment fixes.