Skip to content
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

Adding the convenience Avx.Compare* overloads #34100

Merged
merged 4 commits into from
Mar 26, 2020

Conversation

tannergooding
Copy link
Member

This resolves #31193 by implementing the approved Avx.Compare* convenience overloads. There is no JIT side work for these as they just forward to the existing implementation that takes the FloatComparisonMode enum

CC. @CarolEidt, @echesakovMSFT

@Dotnet-GitSync-Bot
Copy link
Collaborator

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI new-api-needs-documentation labels Mar 25, 2020
@tannergooding
Copy link
Member Author

I found #34094 while implementing these APIs.

Copy link
Contributor

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

LGTM with just one question.

/// CMPPS ymm, ymm/m256, imm8(0)
/// The above native signature does not exist. We provide this additional overload for completeness.
/// </summary>
public static Vector256<float> CompareEqual(Vector256<float> left, Vector256<float> right) => Compare(left, right, FloatComparisonMode.OrderedEqualNonSignaling);
Copy link
Contributor

Choose a reason for hiding this comment

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

@tannergooding Can you explain why CompareEqual corresponds to OrderedEqualNonSignaling while CompareGreaterThan corresponds to OrderedGreaterThanSignaling?

Copy link
Member Author

@tannergooding tannergooding Mar 26, 2020

Choose a reason for hiding this comment

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

The simplest explanation is because that is what the immediate values available to Sse/Sse2 are (imm8 == 0x00 through 0x07, inclusive; 0x08 through 0x1F are Avx+):
image

The lengthier explanation is that Signaling when floating-point exceptions are supported (we don't support and explicitly disable them in .NET) throw for SNaN inputs but not for QNaN. The comparison operations like ==, !=, >, >=, <, and <= don't expect NaN as inputs and so they signal by default; while the Ordered/Unordered comparisons do expect NaN inputs and so they don't.

@tannergooding tannergooding merged commit 044304b into dotnet:master Mar 26, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
@tannergooding tannergooding deleted the fix-31193 branch November 11, 2022 15:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Proposal: Avx.CompareXXX convenience methods for float/double
4 participants