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

Test failure for Sve.GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting() #106815

Closed
SwapnilGaikwad opened this issue Aug 22, 2024 · 4 comments · Fixed by #107165
Closed
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI arm-sve Work related to arm64 SVE/SVE2 support in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@SwapnilGaikwad
Copy link
Contributor

The following failure occurred while running the stress tests starting with name Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting. It's a bit rare failure that I noticed 1 out of 10 runs. Potentially coming from a bug in generating randomised offsets.

===================Running default===================
------------------- {} -------------------
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_int_int() : 22
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_int_uint() : 22
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_long_long() : 22
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_long_ulong() : 22
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_uint_int() : 22
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_uint_uint() : 22
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_ulong_long() : 22
Passed test: _Sve_ro::JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_ulong_ulong() : 22
===================Running jitstress===================
------------------- {'JitMinOpts': '1'} -------------------
------------------- {'JitStress': '1'} -------------------
------------------- {'JitStress': '2'} -------------------
------------------- {'JitStress': '1', 'TieredCompilation': '1'} -------------------
------------------- {'JitStress': '2', 'TieredCompilation': '1'} -------------------
------------------- {'TailcallStress': '1'} -------------------
------------------- {'ReadyToRun': '0'} -------------------
===================Running jitstressregs===================
------------------- {'JitStressRegs': '1'} -------------------
------------------- {'JitStressRegs': '2'} -------------------
------------------- {'JitStressRegs': '3'} -------------------
------------------- {'JitStressRegs': '4'} -------------------
------------------- {'JitStressRegs': '8'} -------------------
------------------- {'JitStressRegs': '0x10'} -------------------
------------------- {'JitStressRegs': '0x80'} -------------------
------------------- {'JitStressRegs': '0x1000'} -------------------
------------------- {'JitStressRegs': '0x2000'} -------------------
===================Running jitstress2-jitstressregs===================
------------------- {'JitStress': '2', 'JitStressRegs': '1'} -------------------
------------------- {'JitStress': '2', 'JitStressRegs': '2'} -------------------
------------------- {'JitStress': '2', 'JitStressRegs': '3'} -------------------
------------------- {'JitStress': '2', 'JitStressRegs': '4'} -------------------
------------------- {'JitStress': '2', 'JitStressRegs': '8'} -------------------
------------------- {'JitStress': '2', 'JitStressRegs': '0x10'} -------------------
------------------- {'JitStress': '2', 'JitStressRegs': '0x80'} -------------------
------------------- {'JitStress': '2', 'JitStressRegs': '0x1000'} -------------------
Test failed:
..........................................
at JIT.HardwareIntrinsics.Arm.Helpers.LoadUInt32FromByteArray(Byte[] array, Int32 offset) in /home/user/dotnet/runtime/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs:line 8089
at JIT.HardwareIntrinsics.Arm.Helpers.GetGatherVectorResultByByteOffset[T,ExtendedElementT,Offset](Int32 index, T[] mask, Byte[] data, Offset[] offsets, T result) in /home/user/dotnet/runtime/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs:line 8656
at JIT.HardwareIntrinsics.Arm.Helpers.CheckFirstFaultingBehaviorCore[T,TFault](T[] result, Vector`1 faultResult, Func`2 checkIter) in /home/user/dotnet/runtime/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs:line 8807
at JIT.HardwareIntrinsics.Arm.Helpers.CheckGatherVectorWithByteOffsetFirstFaultingBehavior[T,ExtendedElementT,Offset,TFault](T[] mask, ExtendedElementT[] data, Offset[] offsets, T[] result, Vector`1 faultResult) in /home/user/dotnet/runtime/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs:line 9005
at JIT.HardwareIntrinsics.Arm._Sve.SveGatherVectorIndices__Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_int_int.ValidateFirstFaultingResult(Int32[] firstOp, UInt32[] secondOp, Int32[] thirdOp, Int32[] result, Vector`1 faultResult, String method) in /home/user/dotnet/runtime/artifacts/tests/coreclr/obj/linux.arm64.Checked/Managed/JIT/HardwareIntrinsics/Arm/Sve/Sve_ro/Sve_ro/gen/Sve.GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting.offsets.int.int.cs:line 738
at JIT.HardwareIntrinsics.Arm._Sve.SveGatherVectorIndices__Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_int_int.ValidateFirstFaultingResult(Void* op1, Byte& op2, Int32 op2Size, Void* op3, Void* result, Vector`1 faultResult, String method) in /home/user/dotnet/runtime/artifacts/tests/coreclr/obj/linux.arm64.Checked/Managed/JIT/HardwareIntrinsics/Arm/Sve/Sve_ro/Sve_ro/gen/Sve.GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting.offsets.int.int.cs:line 733
at JIT.HardwareIntrinsics.Arm._Sve.SveGatherVectorIndices__Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_int_int.RunBasicScenario_LoadFirstFaulting() in /home/user/dotnet/runtime/artifacts/tests/coreclr/obj/linux.arm64.Checked/Managed/JIT/HardwareIntrinsics/Arm/Sve/Sve_ro/Sve_ro/gen/Sve.GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting.offsets.int.int.cs:line 328
at JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting_offsets_int_int() in /home/user/dotnet/runtime/artifacts/tests/coreclr/obj/linux.arm64.Checked/Managed/JIT/HardwareIntrinsics/Arm/Sve/Sve_ro/Sve_ro/gen/Sve.GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting.offsets.int.int.cs:line 39
at Program.<<Main>$>g__TestExecutor3284|0_3285(StreamWriter tempLogSw, StreamWriter statsCsvSw, <>c__DisplayClass0_0&) in /home/user/dotnet/runtime/artifacts/tests/coreclr/obj/linux.arm64.Checked/Managed/JIT/HardwareIntrinsics/HardwareIntrinsics_Arm_ro/generated/XUnitWrapperGenerator/XUnitWrapperGenerator.XUnitWrapperGenerator/FullRunner.g.cs:line 83031
------------------- {'JitStress': '2', 'JitStressRegs': '0x2000'} -------------------
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 22, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 22, 2024
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@amanasifkhalid
Copy link
Member

I was able to hit this failure with a similar JitStress configuration while testing GatherVectorWithByteOffsetFirstFaulting:

------------------- {'JitStress': '2', 'JitStressRegs': '3'} -------------------
Test failed:
..........................................
   at JIT.HardwareIntrinsics.Arm.Helpers.LoadUInt32FromByteArray(Byte[] array, Int32 offset) in C:\wk\runtime\src\tests\JIT\HardwareIntrinsics\Arm\Shared\Helpers.cs:line 8050
   at JIT.HardwareIntrinsics.Arm.Helpers.GetGatherVectorResultByByteOffset[T,Offset](Int32 index, T[] mask, Byte[] data, Offset[] offsets, T result) in C:\wk\runtime\src\tests\JIT\HardwareIntrinsics\Arm\Shared\Helpers.cs:line 8591
   at JIT.HardwareIntrinsics.Arm.Helpers.<>c__DisplayClass1462_0`4.<CheckGatherVectorWithByteOffsetFirstFaultingBehavior>b__1(Int32 i) in C:\wk\runtime\src\tests\JIT\HardwareIntrinsics\Arm\Shared\Helpers.cs:line 8911
   at JIT.HardwareIntrinsics.Arm.Helpers.CheckFirstFaultingBehaviorCore[T,TFault](T[] result, Vector`1 faultResult, Func`2 checkIter) in C:\wk\runtime\src\tests\JIT\HardwareIntrinsics\Arm\Shared\Helpers.cs:line 8726
   at JIT.HardwareIntrinsics.Arm.Helpers.CheckGatherVectorWithByteOffsetFirstFaultingBehavior[T,ExtendedElementT,Offset,TFault](T[] mask, ExtendedElementT[] data, Offset[] offsets, T[] result, Vector`1 faultResult) in C:\wk\runtime\src\tests\JIT\HardwareIntrinsics\Arm\Shared\Helpers.cs:line 8911
   at JIT.HardwareIntrinsics.Arm._Sve.SveGatherVectorIndices__Sve_GatherVectorWithByteOffsetFirstFaulting_uint_int.ValidateFirstFaultingResult(UInt32[] firstOp, UInt32[] secondOp, Int32[] thirdOp, UInt32[] result, Vector`1 faultResult, String method) in C:\wk\runtime\artifacts\tests\coreclr\obj\windows.arm64.Release\Managed\JIT\HardwareIntrinsics\Arm\Sve\Sve_ro\Sve_ro\gen\Sve.GatherVectorWithByteOffsetFirstFaulting.uint.int.cs:line 748
   at JIT.HardwareIntrinsics.Arm._Sve.SveGatherVectorIndices__Sve_GatherVectorWithByteOffsetFirstFaulting_uint_int.RunBasicScenario_LoadFirstFaulting() in C:\wk\runtime\artifacts\tests\coreclr\obj\windows.arm64.Release\Managed\JIT\HardwareIntrinsics\Arm\Sve\Sve_ro\Sve_ro\gen\Sve.GatherVectorWithByteOffsetFirstFaulting.uint.int.cs:line 338
   at JIT.HardwareIntrinsics.Arm._Sve.Program.Sve_GatherVectorWithByteOffsetFirstFaulting_uint_int() in C:\wk\runtime\artifacts\tests\coreclr\obj\windows.arm64.Release\Managed\JIT\HardwareIntrinsics\Arm\Sve\Sve_ro\Sve_ro\gen\Sve.GatherVectorWithByteOffsetFirstFaulting.uint.int.cs:line 39
   at Program.<<Main>$>g__TestExecutor3230|0_3231(StreamWriter tempLogSw, StreamWriter statsCsvSw, <>c__DisplayClass0_0&) in C:\wk\runtime\artifacts\tests\coreclr\obj\windows.arm64.Release\Managed\JIT\HardwareIntrinsics\HardwareIntrinsics_Arm_ro\generated\XUnitWrapperGenerator\XUnitWrapperGenerator.XUnitWrapperGenerator\FullRunner.g.cs:line 81655

So this failure isn't unique to GatherVectorUInt32WithByteOffsetsZeroExtendFirstFaulting.

@JulieLeeMSFT JulieLeeMSFT added arm-sve Work related to arm64 SVE/SVE2 support and removed untriaged New issue has not been triaged by the area owner labels Aug 23, 2024
@JulieLeeMSFT JulieLeeMSFT added this to the 9.0.0 milestone Aug 27, 2024
@amanasifkhalid amanasifkhalid self-assigned this Aug 29, 2024
@amanasifkhalid
Copy link
Member

This failure is slightly different from the one detailed in #106621, though my solution to that issue should fix this one, too. Suppose our bounded memory is five bytes (like [0, 1, 2, 3, 4]), and we want to read a 32-bit integer starting from byte offset 1. Intuitively, this shouldn't fault. In ValidateFirstFaultingResult, we convert the byte array into an integer array, chopping off the last byte. Then in CheckGatherVectorWithByteOffsetFirstFaultingBehavior, we convert this integer array back to a byte array, but we calculate the size of the byte array as data.Length * Unsafe.SizeOf<Int32>(), or 4, so the byte array is [0, 1, 2, 3] -- we've lost the last byte completely. So although the actual load operation didn't fault, when we try to replicate it with LoadInt32FromByteArray starting from byte 1, we will walk off the end of the array.

We shouldn't need to convert the bounded memory to an intermediate array of ints/floats/etc at all. Rather, we can tweak CheckGatherVectorWithByteOffsetFirstFaultingBehavior to take a byte array as input, and simply pass BoundedMemory<byte>.Span.ToArray() to it. This way, we don't risk any data loss from miscalculated array sizes.

@amanasifkhalid amanasifkhalid modified the milestones: 9.0.0, 10.0.0 Aug 29, 2024
@dotnet-policy-service dotnet-policy-service bot added the in-pr There is an active PR which will close this issue when it is merged label Aug 29, 2024
@SwapnilGaikwad
Copy link
Contributor Author

We shouldn't need to convert the bounded memory to an intermediate array of ints/floats/etc at all.

Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI arm-sve Work related to arm64 SVE/SVE2 support in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants