ARM64-SVE: Add TrigonometricMultiplyAddCoefficient#104697
ARM64-SVE: Add TrigonometricMultiplyAddCoefficient#104697amanasifkhalid merged 6 commits intodotnet:mainfrom
TrigonometricMultiplyAddCoefficient#104697Conversation
|
Note regarding the |
1 similar comment
|
Note regarding the |
|
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics |
kunalspathak
left a comment
There was a problem hiding this comment.
Added some questions around test.
| public void RunStructFldScenario({TemplateName}BinaryOpTest__{TestName} testClass) | ||
| { | ||
| var result = {Isa}.{Method}(_fld1, _fld2, {Imm}); | ||
| var result = {Isa}.{Method}(_fld1, _fld2, Imm); |
There was a problem hiding this comment.
This is missing a test where we pass invalidImm as input. See test.RunBasicScenario_UnsafeRead_InvalidImm in _SveImmUnaryOpTestTemplate.template for example.
There was a problem hiding this comment.
Got it. I noticed the InvalidImm tests in other templates look like this:
bool succeeded = false;
try
{
var result = {Isa}.{Method}(
Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr),
{InvalidImm}
);
}
catch (ArgumentOutOfRangeException)
{
succeeded = true;
}We aren't doing anything with succeeded. Is this intentional?
There was a problem hiding this comment.
We aren't doing anything with
succeeded. Is this intentional?
Unfortunately, it is not. It is missing this code:
if (!succeeded)
{
Succeeded = false;
}Opened #104809 to track it. Feel free to just update this one and for others we will take care of as part of fixing the overall issue.
| public static float TrigonometricMultiplyAddCoefficient(float op1, float op2, byte imm) | ||
| { | ||
| int index = (op2 < 0) ? (imm + 8) : imm; | ||
| uint coeff = index switch |
There was a problem hiding this comment.
@SwapnilGaikwad - can you please confirm this logic verifies the operation of the instruction?
| Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray1Ptr), | ||
| Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArray2Ptr), | ||
| (byte){Imm} | ||
| (byte)Imm |
There was a problem hiding this comment.
By having Imm, we will always generate table driven logic, while with {Imm}, we will always generate the single instruction, with constant embedded. I think we need to have a test for both and I have captured it in #104809. Please revert these changes and we will address them together as part of that issue.
There was a problem hiding this comment.
Got it, I did this out of convenience for writing the test definitions: If we do {Imm}, then we cannot dynamically generate the immediate value using something like TestLibrary.Generator.GetByte() because the value will change each time we use {Imm}. Instead, we'll have to hard-code the immediate into the test with something like ["Imm"] = "0". I don't mind doing this; it will just result in more tests for this API.
|
|
||
| public static float TrigonometricMultiplyAddCoefficient(float op1, float op2, byte imm) | ||
| { | ||
| int index = (op2 < 0) ? (imm + 8) : imm; |
There was a problem hiding this comment.
have we verified the behavior of this API with invalid values? If it is undefined, are we making the test robust to handle it?
There was a problem hiding this comment.
Like in #104681, the tests seem to work fine with out-of-bound values, though I can easily modify the tests to skip validation for such values.
There was a problem hiding this comment.
I liked the way you have combined the table of sin and cos in a single lookup.
There was a problem hiding this comment.
Like in #104681, the tests seem to work fine with out-of-bound values, though I can easily modify the tests to skip validation for such values.
That will be great.
There was a problem hiding this comment.
I liked the way you have combined the table of sin and cos in a single lookup.
Thanks, I wish I could say that was my idea, but the ARM docs suggested it
|
@kunalspathak I addressed your feedback. I had to add a usage of the intrinsic's result in the |
kunalspathak
left a comment
There was a problem hiding this comment.
Overall looks good. please make sure we skip the validation for invalid input as well as make sure the other tests using the modified template passes.
| test.ConditionalSelect_ZeroOp(); | ||
|
|
||
| // Validates basic functionality fails with an invalid imm, using Unsafe.ReadUnaligned | ||
| test.RunBasicScenario_UnsafeRead_InvalidImm(); |
There was a problem hiding this comment.
This template is used by *MultiplyBySelectedScalar* too. Have you verified if those tests pass, including the stress?
|
|
||
| public static float TrigonometricMultiplyAddCoefficient(float op1, float op2, byte imm) | ||
| { | ||
| int index = (op2 < 0) ? (imm + 8) : imm; |
There was a problem hiding this comment.
I liked the way you have combined the table of sin and cos in a single lookup.
|
|
||
| public static float TrigonometricMultiplyAddCoefficient(float op1, float op2, byte imm) | ||
| { | ||
| int index = (op2 < 0) ? (imm + 8) : imm; |
There was a problem hiding this comment.
Like in #104681, the tests seem to work fine with out-of-bound values, though I can easily modify the tests to skip validation for such values.
That will be great.
|
@kunalspathak I merged from main and reran the stress tests for |
Part of #99957. @dotnet/arm64-contrib PTAL, thanks!
Test output: