-
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
[RISC-V] Test HalfTest: fixed payload preservation testcase for RISC-V #96888
[RISC-V] Test HalfTest: fixed payload preservation testcase for RISC-V #96888
Conversation
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/HalfTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/HalfTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/HalfTests.cs
Outdated
Show resolved
Hide resolved
@tannergoodin, I found that float->half and double->half cast algorithms are not similar. Is there a reason for such difference? |
The |
@tannergooding, @jkotas, can this PR be merged? |
src/libraries/Common/tests/TestUtilities/System/AssertExtensions.cs
Outdated
Show resolved
Hide resolved
3e485de
to
1ffe5fa
Compare
@@ -1130,7 +1130,7 @@ public static void Equal(Half expected, Half actual, Half variance) | |||
/// <exception cref="EqualException">Thrown when the representations are not identical</exception> | |||
public static void Equal(double expected, double actual) | |||
{ | |||
if (BitConverter.ToInt64(BitConverter.GetBytes(expected)) == BitConverter.ToInt64(BitConverter.GetBytes(actual))) | |||
if (BitConverter.ToInt64(BitConverter.GetBytes(expected), 0) == BitConverter.ToInt64(BitConverter.GetBytes(actual), 0)) |
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 should be BitConverter.DoubleToInt64Bits(expected) == BitConverter.DoubleToInt64Bits(actual)
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.
and similarly for the ones further down. For float
on .NET Framework, I'd just define a helper:
static unsafe int SingleToInt32Bits(float value)
{
return *(int*)&value;
}
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, thank you for suggestion. By the way I didn't find anything in the supported product list for the BitConverter.HalfToInt16Bits
function in .NET API Catalog except the .NET version
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.
The official API docs include the .NET versions its been included in: https://learn.microsoft.com/en-us/dotnet/api/system.bitconverter.halftoint16bits#applies-to
@tannergooding, seems like the remaining CI failures are not caused by PR, could you review please? |
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsArithmetic operations with NaN does not preserve payload on RISC-V. And explicit conversion operators in Half class use arithmetic operations with float. That is why payload preservation test cases are failed for RISC-V. This fixes payload preservation testcases in:
Part of #84834
|
Thank you all for review! |
Arithmetic operations with NaN does not preserve payload on RISC-V. And explicit conversion operators in Half class use arithmetic operations with float. That is why payload preservation test cases are failed for RISC-V.
This fixes payload preservation testcases in:
Part of #84834
cc @tannergooding @gbalykov @t-mustafin @clamp03 @tomeksowi