[RISC-V] Test HalfTest: fixed payload preservation testcase for RISC-V#96888
[RISC-V] Test HalfTest: fixed payload preservation testcase for RISC-V#96888tannergooding merged 14 commits intodotnet:mainfrom
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
| 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.
This should be BitConverter.DoubleToInt64Bits(expected) == BitConverter.DoubleToInt64Bits(actual)
There was a problem hiding this comment.
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.
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.
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