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/Sve: Implement LoadVector*NonFaultingSignExtendTo* APIs #102903

Merged
merged 10 commits into from
May 31, 2024

Conversation

kunalspathak
Copy link
Member

Copy link

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, 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.

@kunalspathak
Copy link
Member Author

@dotnet/arm64-contrib @TIHan PTAL

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics
See info in area-owners.md if you want to be subscribed.

@kunalspathak kunalspathak added the arm-sve Work related to arm64 SVE/SVE2 support label May 30, 2024
Copy link
Contributor

@TIHan TIHan left a comment

Choose a reason for hiding this comment

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

LGTM. Minor comment on the category. Test template works great.

("SveLoadMaskedUnOpTest.template", new Dictionary<string, string> { ["TestName"] = "SveLoadVectorUInt16ZeroExtendToUInt64", ["Isa"] = "Sve", ["Method"] = "LoadVectorUInt16ZeroExtendToUInt64", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt16()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}),
("SveLoadMaskedUnOpTest.template", new Dictionary<string, string> { ["TestName"] = "SveLoadVectorUInt32ZeroExtendToInt64", ["Isa"] = "Sve", ["Method"] = "LoadVectorUInt32ZeroExtendToInt64", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Int64", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}),
("SveLoadMaskedUnOpTest.template", new Dictionary<string, string> { ["TestName"] = "SveLoadVectorUInt32ZeroExtendToUInt64", ["Isa"] = "Sve", ["Method"] = "LoadVectorUInt32ZeroExtendToUInt64", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}),
("SveLoadMaskedUnOpTest.template", new Dictionary<string, string> { ["TestName"] = "Sve_LoadVector_float", ["Isa"] = "Sve", ["Method"] = "LoadVector", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "firstOp[i] != result[i]"}),
Copy link
Contributor

Choose a reason for hiding this comment

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

What did you change on these lines? Was it just the TestName?

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, just to have them consistent naming of Sve_*

// Validates passing an instance member of a struct works
test.RunStructFldScenario();

// Validates using inside ConditionalSelect with value falseValue
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 surprised we've not hit this before - there are other instructions that are Pg/Z.

Copy link
Member Author

Choose a reason for hiding this comment

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

All the APIs we have implemented that has Pg/Z are either the ones that explicitly takes mask as first argument like LoadVector for which we don't use it inside ConditionalSelect or the ones that operates on purely predicate registers like EOR Presult.B, Pg/Z, Pop1.B, Pop2.B which we have not exposed it via API. This is the first API that implicitly has a mask argument and has Pg/Z format in the instruction.


// Validates using inside ConditionalSelect with zero falseValue
test.ConditionalSelect_ZeroOp();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe not for this PR, but I remember discussion about testing with addresses that fault. Use an address that is invalid/partially invalid, then test an exception is not raised.
Then maybe add the same test to the normal loads and check it does fault.

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, @TIHan added that in #102180

//TODO-SVE: Once register allocation exists for predicates, move loadMask into DataTable
{Op1VectorType}<{Op1BaseType}> loadTrueMask = Sve.CreateTrueMask{RetBaseType}(SveMaskPattern.All);
{Op1VectorType}<{Op1BaseType}> loadFalseMask = Sve.CreateFalseMask{RetBaseType}();
var result = {Isa}.{Method}(loadTrueMask, ({Op1BaseType}*)(_dataTable.inArrayPtr));
try
{
result = {Isa}.{Method}(loadFalseMask, default);
Unsafe.Write(_dataTable.outArray1Ptr, result.Item1);
Unsafe.Write(_dataTable.outArray2Ptr, result.Item2);
ValidateZeroResult(_dataTable.outArray1Ptr, _dataTable.outArray2Ptr, _dataTable.inArrayPtr);
}
catch
{
Succeeded = false;
}

@@ -0,0 +1,413 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's special about this template that means it can't use the standard load template?

Copy link
Member Author

Choose a reason for hiding this comment

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

Having a RunBasicScenario_LoadNonFaulting() test case that will make sure we do not fault even for invalid memory.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was looking for a try/catch ... but we don't need to add that.

@kunalspathak
Copy link
Member Author

/ba-g opened #102919

@kunalspathak kunalspathak merged commit 214cbbf into dotnet:main May 31, 2024
163 of 167 checks passed
@kunalspathak kunalspathak deleted the loadvector-1 branch May 31, 2024 13:09
@github-actions github-actions bot locked and limited conversation to collaborators Jul 1, 2024
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.

3 participants