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

[Arm64] ASIMD DotProduct and Rounding Double Multiply Add/Subtract #38957

Conversation

echesakov
Copy link
Contributor

@echesakov echesakov commented Jul 8, 2020

  • DotProduct

  • DotProductBySelectedQuadruplet

  • MultiplyRoundedDoublingAndAddSaturateHigh

  • MultiplyRoundedDoublingAndAddSaturateHighScalar

  • MultiplyRoundedDoublingAndSubtractSaturateHigh

  • MultiplyRoundedDoublingAndSubtractSaturateHighScalar

  • MultiplyRoundedDoublingBySelectedScalarAndAddSaturateHigh

  • MultiplyRoundedDoublingBySelectedScalarAndSubtractSaturateHigh

  • MultiplyRoundedDoublingScalarBySelectedScalarAndAddSaturateHigh

  • MultiplyRoundedDoublingScalarBySelectedScalarAndSubtractSaturateHigh

Fixes #37169
Fixes #36696

With help from @eiriktsarpalis I collected the test results on an Arm64 device that supports these ISAs - I attached the archive with the files.

Dp_Rdm_Rdm.Arm64.zip

@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 Jul 8, 2020
@echesakov echesakov added arch-arm64 area-System.Runtime.Intrinsics and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI new-api-needs-documentation labels Jul 9, 2020
@ghost
Copy link

ghost commented Jul 9, 2020

Tagging subscribers to this area: @tannergooding
Notify danmosemsft if you want to be subscribed.

@echesakov echesakov force-pushed the Arm64-ASIMD-DotProduct-Rounding-Double-Multiply-Add-Subtract branch from 55e7c8b to 478fef1 Compare July 9, 2020 02:46
@echesakov echesakov marked this pull request as ready for review July 9, 2020 18:51
@echesakov
Copy link
Contributor Author

@CarolEidt @tannergooding @TamarChristinaArm This is ready for review, please take a look.

@@ -28,8 +28,11 @@ enum CORINFO_InstructionSet
InstructionSet_Sha1=8,
InstructionSet_Sha256=9,
InstructionSet_Atomics=10,
InstructionSet_Vector64=11,
InstructionSet_Vector128=12,
InstructionSet_Dp=11,
Copy link
Member

Choose a reason for hiding this comment

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

Dp_Arm64 should also exist, it isn't covered by #38460

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will update/rebase this PR after you merge #38460

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

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.

This LGTM overall, with one question. It seems that you and @tannergooding will have to coordinate with his #38460 (i.e. one will have to merge)

public static new bool IsSupported { get => IsSupported; }

[Intrinsic]
public new abstract class Arm64 : AdvSimd.Arm64
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused why this is here if there are no 64-bit intrinsics in this class.

Copy link
Contributor Author

@echesakov echesakov Jul 9, 2020

Choose a reason for hiding this comment

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

I added this as a placeholder and I anticipated to wait till Tanner merges his PR and update thereafter. I believe this is needed to be consistent with #34587.

Copy link
Contributor Author

@echesakov echesakov Jul 9, 2020

Choose a reason for hiding this comment

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

My understanding that Dp.Arm64.IsSupported needs to return false if Dp.IsSupported is false.
While now Dp.Arm64.IsSupported returns true if AdvSimd.Arm64.IsSupported is true, so we need to treat Dp.Arm64.IsSupported as intrinsic instead of relying on it being inherited from AdvSimd.Arm64.

Copy link
Member

Choose a reason for hiding this comment

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

Dp.Arm64.IsSupported needs to return true if Dp.IsSupported and we are in a 64-bit process. It being true implies Dp.IsSupported and ArmBase.Arm64.IsSupported (which each also implies ArmBase.IsSupported).

Having it recursive here and adding the relevant entry to Arm64VersionOfIsa should hook it all up correctly (same as was done for Rdm: https://github.com/dotnet/runtime/pull/38957/files#diff-8e07abb3dff9bfe2e051a071c787f18bR27)

It exists because of #34587 (and is the same reason as #38460 was created), which is that we otherwise get into weird scenarios where Dp.Arm64.IsSupported can return true (because it actually resolves to ArmBase.Arm64.IsSupported when Dp.IsSupported returns false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@CarolEidt Do you have any other questions here?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, makes sense (sort of!)

@@ -50,8 +50,8 @@ PAL_GetJitCpuCapabilityFlags(CORJIT_FLAGS *flags)
// CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_DCPOP);
#endif
#ifdef HWCAP_ASIMDDP
// if (hwCap & HWCAP_ASIMDDP)
// CPUCompileFlags.Set(CORJIT_FLAGS::CORJIT_FLAG_HAS_ARM64_DP);
if (hwCap & HWCAP_ASIMDDP)
Copy link
Member

Choose a reason for hiding this comment

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

We should add a tracking issue with the tracking-external-issue label for when Windows support is in, so we can update the codeman checks for Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done #39094

@@ -140,20 +158,19 @@ bool HWIntrinsicInfo::isFullyImplementedIsa(CORINFO_InstructionSet isa)
case InstructionSet_ArmBase_Arm64:
case InstructionSet_Crc32:
case InstructionSet_Crc32_Arm64:
case InstructionSet_Dp:
Copy link
Member

Choose a reason for hiding this comment

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

Missing Dp_Arm64?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@tannergooding
Copy link
Member

It would be good to update JIT/Regression/JitBlue/Runtime_34587 to validate the hierarchy of the new ISAs

@echesakov
Copy link
Contributor Author

It would be good to update JIT/Regression/JitBlue/Runtime_34587 to validate the hierarchy of the new ISAs

It looks that this tests was merged in the wrong place (under src/coreclr/tests/src instead of src/tests) - I will move it and update as you suggested

@echesakov
Copy link
Contributor Author

@tannergooding Updated the test. Unfortunatelly, it does not do anything in CI now since our machines don't support Dp and Rdm

@tannergooding
Copy link
Member

Unfortunatelly, it does not do anything in CI now since our machines don't support Dp and Rdm

That's unfortunate, but possibly something we can address longer term. This scenario will be an issue (in the future) as we start onboarding newer ISAs

@echesakov
Copy link
Contributor Author

@tannergooding I am going to merge this to unblock the remaining hardware intrinsics work.
Please let me know, if you want me to follow up on anything else here.

@echesakov echesakov merged commit d9a7d8f into dotnet:master Jul 13, 2020
@echesakov echesakov deleted the Arm64-ASIMD-DotProduct-Rounding-Double-Multiply-Add-Subtract branch July 13, 2020 18:49
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Arm64] SIMD dot product ARM Doubling Multiply intrinsics
4 participants