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

[libs] Skip AdvSimdEncode on Mono #96829

Merged
merged 6 commits into from
Jan 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ private static unsafe void Avx2Encode(ref byte* srcBytes, ref byte* destBytes, b
[CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
private static unsafe void AdvSimdEncode(ref byte* srcBytes, ref byte* destBytes, byte* srcEnd, int sourceLength, int destLength, byte* srcStart, byte* destStart)
{
#if MONO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to do this at the callsite of AdvSimdEncod.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add an extra guard to the current caller of AdvSimdEncode. I think the current callsite would just fall through to the next block of logic, so I didn't add it in the first place.

I think we should still have the block on AdvSimdEncode in case more invocations are added, because the PNSE is hit inside of AdvSimdEncode.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hhm, wondering why this should be at the callsite rather than just inside AdvSimdEncode? Also can you add a comment about why this is under a #if !MONO pointing to the #96828 (comment)?

In caller, you could just have without #else

#if MONO
 return;
#endif

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because at the callsite, there is a check to see if AdvSimd is supported to decide to call AdvSimdEncode or not. So I feel logically, it makes more sense to do it there. Functional wise, either way should be fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointing to the #96828 (comment)?

point it to #93081

there is a check to see if AdvSimd is supported

Right, but that is true even for Mono and should be ok. At least if there are more callers, we won't have to worry about adding the #if everywhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to guard the entire method


I believe that Mono reporting IsSupported but functions not being supported might be attributed to #84510 not accounting for Mono. The volume of mono tests is far too time consuming + non-zero flakey tests to run on all PRs by default. Hence a runtime-extra-platforms lane was introduced, which was intended to be ran for PRs that make changes affecting Mono.

There is a smoke test being ran by default, but that is just System.Runtime.Tests.csproj. We could increase the number of suites that are ran as smoke tests, but that is another question of what other suites should be added that reliably dont flake. It looks like there are HWIntrinsics runtime tests, but guessing it doesn't run for Mono?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think mono specific pipelines are run today if the changes are not related to mono. runtime-extra-platforms would be a good remainder to run for such cases. Regarding, IsSupported, what is a good option here? Although logically correct to have AdvSimd.IsSupported == false until those APIs are not implemented in mono, but that would mean that mono won't have any of the other AdvSimd features too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BCL change should trigger mono CI lanes which run library tests to run. If not, it is an issue worth looking into.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are new API's, I doubt the customer would use them right away. So I would prefer leaving AdvSimd.IsSupported == true as it is now and implement the new API's soon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: tests, I think this is a case where we didn't have adequate coverage in our smoke tests. The good thing is that we discovered it right away via extra-platforms and we can take action.

With us running a reduced set of tests for iOS devices (full aot LLVM), this is going to happen. As Mitch was getting at, my suggestion would be to add another suite to the smoke tests that we run so that there's a reasonable chance we would fail on something like this in the future.

return;
#else
// C# implementatino of https://github.com/aklomp/base64/blob/3a5add8652076612a8407627a42c768736a4263f/lib/arch/neon64/enc_loop.c
Vector128<byte> str1;
Vector128<byte> str2;
Expand Down Expand Up @@ -545,6 +548,7 @@ private static unsafe void AdvSimdEncode(ref byte* srcBytes, ref byte* destBytes

srcBytes = src;
destBytes = dest;
#endif
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down
Loading