Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: maximum, minimum no longer emit warnings on NAN #12236

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

Merged
merged 4 commits into from
Oct 29, 2018

Conversation

mattip
Copy link
Member

@mattip mattip commented Oct 21, 2018

Fixes #12038.

Starting with the sse code in simd.inc.src in PR #3419, then completed in PRs #9020, #11043, #11595, we adopted behaviour that warned when encountering a NAN on np.maximum, np.minimum, as well as ensuring we return a NAN value. This PR reverts emitting a warning, while preserving the tests to show we always propogate the NAN value to the output.

}
/* npy_half_isnan will never set floatstatus_invalid, so do not clear */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when do we set floatstatus_invalid? is that set at the C level?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the non-SSE code sets it in a > b comparisons. which is why I need to clear it in the float-type loops at line 1849, and the complex-type loops at line 2763,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, set at the FPU level, not at the C level.

Can't we just reorder the comparisons to do the nan checks first, rather than messing with the FPU flags?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying, let's see what CI finds

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out simd code also sets it, in a way that it is impossible to avoid the clear after the loop finishes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rearranging the order still sets the flag since only one value is checked. It seems cheaper to me to clear the flag than to check both values. In changeset 46452b3 I added back the call to clear the flags, now tests are passing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think instruction ordering is safe with modern compilers, at least without some work to make the order stick.

@charris charris merged commit 96432ea into numpy:master Oct 29, 2018
@charris
Copy link
Member

charris commented Oct 29, 2018

Thanks Matti.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants