-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT ARM64-SVE: Add Sve.ConditionalExtract* APIs #104150
JIT ARM64-SVE: Add Sve.ConditionalExtract* APIs #104150
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics |
@kunalspathak @dotnet/arm64-contrib @a74nh |
@TIHan - can you please take a preliminary look? |
Did you already synced with |
I'm not sure, could you specify the commit in question so I can check? |
#104065. Please sync with |
5400b45
to
97c9682
Compare
Thank you, @kunalspathak , I can confirm that the tests pass successfully now:
|
|
||
/// <summary> | ||
/// svint16_t svclasta[_s16](svbool_t pg, svint16_t fallback, svint16_t data) | ||
/// CLASTA Ztied.H, Pg, Ztied.H, Zdata.H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instruction maps to the API that takes Vector<T>
for defaultValue
parameter. Please remove it from here and at other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
...braries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs
Outdated
Show resolved
Hide resolved
{ | ||
opt = emitter::optGetSveInsOpt(emitTypeSize(node->GetSimdBaseType())); | ||
|
||
if (emitter::isGeneralRegisterOrZR(targetReg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be an assert instead? assert(emitter::isGeneralRegisterOrZR(targetReg));
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or are we using the term *Scalar
for instructions that are generated for https://docsmirror.github.io/A64/2023-06/clasta_r_p_z.html and https://docsmirror.github.io/A64/2023-06/clasta_v_p_z.html?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLASTA (scalar) is emitted only for integer *Scalar
APIs. For floating-point *Scalar
APIs we have to emit CLASTA (SIMD&FP scalar) instead.
@@ -3914,6 +3917,67 @@ | |||
("SveVecReduceUnOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ZeroExtendWideningUpper_uint_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZeroExtendWideningUpper", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateReduceOpResult"] = "Helpers.ZeroExtendWideningUpper(firstOp, 0) != result[0]", ["ValidateRemainingResults"] = "Helpers.ZeroExtendWideningUpper(firstOp, i) != result[i]"}), | |||
("SveVecReduceUnOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ZeroExtendWideningUpper_ulong_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZeroExtendWideningUpper", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateReduceOpResult"] = "Helpers.ZeroExtendWideningUpper(firstOp, 0) != result[0]", ["ValidateRemainingResults"] = "Helpers.ZeroExtendWideningUpper(firstOp, i) != result[i]"}), | |||
|
|||
("SveVecTernOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ConditionalExtractAfterLastActiveElement_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalExtractAfterLastActiveElement", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(firstOp, secondOp, thirdOp)[i] != result[i]", ["GetIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(first, second, third)[i]", ["ConvertFunc"] = ""}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please place these in alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -3914,6 +3917,67 @@ | |||
("SveVecReduceUnOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ZeroExtendWideningUpper_uint_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZeroExtendWideningUpper", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateReduceOpResult"] = "Helpers.ZeroExtendWideningUpper(firstOp, 0) != result[0]", ["ValidateRemainingResults"] = "Helpers.ZeroExtendWideningUpper(firstOp, i) != result[i]"}), | |||
("SveVecReduceUnOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ZeroExtendWideningUpper_ulong_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZeroExtendWideningUpper", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateReduceOpResult"] = "Helpers.ZeroExtendWideningUpper(firstOp, 0) != result[0]", ["ValidateRemainingResults"] = "Helpers.ZeroExtendWideningUpper(firstOp, i) != result[i]"}), | |||
|
|||
("SveVecTernOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ConditionalExtractAfterLastActiveElement_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalExtractAfterLastActiveElement", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(firstOp, secondOp, thirdOp)[i] != result[i]", ["GetIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(first, second, third)[i]", ["ConvertFunc"] = ""}), | |||
("SveScalarTernOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ConditionalExtractAfterLastActiveElement_float_scalar", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalExtractAfterLastActiveElement", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateScalarResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(firstOp, secondOp, thirdOp) != result"}), | |||
("SveVecTernOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ConditionalExtractAfterLastActiveElement_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalExtractAfterLastActiveElement", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(firstOp, secondOp, thirdOp)[i] != result[i]", ["GetIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(first, second, third)[i]", ["ConvertFunc"] = ""}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, it will be good to group the same APIs under test together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Looks like I missed several issues while testing the updated changes locally. Please wait 'till they are resolved before re-reviewing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Ah just seeing this message. Will reset the approval status. |
0b82f53
to
b0212ca
Compare
Updated, the stress testing passes. |
src/coreclr/jit/gentree.cpp
Outdated
NI_Sve_GatherVectorUInt16WithByteOffsetsZeroExtend, NI_Sve_GatherVectorUInt16ZeroExtend, | ||
NI_Sve_GatherVectorUInt32WithByteOffsetsZeroExtend, NI_Sve_GatherVectorUInt32ZeroExtend)); | ||
assert(varTypeIsI(addr) || (varTypeIsSIMD(addr) && ((intrinsicId >= NI_Sve_GatherVector) && | ||
AreContiguous(NI_Sve_GatherPrefetch16Bit, NI_Sve_GatherPrefetch32Bit, NI_Sve_GatherPrefetch64Bit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed after #104396. Can you please merge the main
and revert this?
@@ -4087,6 +4090,67 @@ | |||
("SveVecReduceUnOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ZeroExtendWideningUpper_uint_ushort", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZeroExtendWideningUpper", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateReduceOpResult"] = "Helpers.ZeroExtendWideningUpper(firstOp, 0) != result[0]", ["ValidateRemainingResults"] = "Helpers.ZeroExtendWideningUpper(firstOp, i) != result[i]"}), | |||
("SveVecReduceUnOpTest.template",new Dictionary<string, string> {["TestName"] = "Sve_ZeroExtendWideningUpper_ulong_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ZeroExtendWideningUpper", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateReduceOpResult"] = "Helpers.ZeroExtendWideningUpper(firstOp, 0) != result[0]", ["ValidateRemainingResults"] = "Helpers.ZeroExtendWideningUpper(firstOp, i) != result[i]"}), | |||
|
|||
("SveVecTernOpTest.template", new Dictionary<string, string> { ["TestName"] = "Sve_ConditionalExtractAfterLastActiveElement_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalExtractAfterLastActiveElement", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(firstOp, secondOp, thirdOp)[i] != result[i]",["GetIterResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(first, second, third)[i]", ["ConvertFunc"] = " ",}), | |||
("SveScalarTernOpTest.template", new Dictionary<string, string> { ["TestName"] = "Sve_ConditionalExtractAfterLastActiveElement_float_scalar", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalExtractAfterLastActiveElement", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateScalarResult"] = "Helpers.ConditionalExtractAfterLastActiveElement(firstOp, secondOp, thirdOp) != result",}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please align the lines for the newly added tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Testing
Regular tests pass successfully. Stress testing highlights two issues. The first one as I believe is already know and decided to be fixed later. It results in a method returning a value as if a mask/predicate register were all false despite that error output show that it's not, e.g.
The second one manifests in a form of a method returning a zeroed vector. It generally looks like the following and appears for all kinds of types and ConditinalExtract* APIs but only for RunBasicScenario_Load tests:
A one would expect the
result
to be(92, ... , 92)
here or(83, 22, 34, 122, 111, 34, 25, 103, 44, 98, 37, 4, 13, 85, 93, 12)
(same assecondOp
) if the first issue discussed above manifested here. But all zeros are something different. This behavior can be attributed to the first issue if we consider how it can interfere withRunBasicScenario_Load
: ifloadMask3
is all false (incorrectly as the effect of the first issue), then both the third arg and the result ofConditionalExtractAfterLastActiveElementAndReplicate
would be all zeroes. The same would happen in case allloadMask*
s are all false. We would see different results if only eitherloadMask1
orloadMask2
is all false, but I can't see anything like that in the logs.Test logs
ConditionalExtract-stress.txt