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

Conversation

mdh1418
Copy link
Member

@mdh1418 mdh1418 commented Jan 11, 2024

Works around #96828

Not sure if the problematic code affects all of mono arm64 configurations or just ios/tvos arm64.

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 11, 2024
@ghost ghost assigned mdh1418 Jan 11, 2024
@mdh1418
Copy link
Member Author

mdh1418 commented Jan 11, 2024

/azp run runtime-extra-platforms

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@vargaz
Copy link
Contributor

vargaz commented Jan 11, 2024

Shouldn't the #if MONO be in the caller ?

@@ -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.

@am11 am11 added area-System.Buffers and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 11, 2024
@ghost
Copy link

ghost commented Jan 11, 2024

Tagging subscribers to this area: @dotnet/area-system-buffers
See info in area-owners.md if you want to be subscribed.

Issue Details

Works around #96828

Not sure if the problematic code affects all of mono arm64 configurations or just ios/tvos arm64.

Author: mdh1418
Assignees: mdh1418
Labels:

area-System.Buffers

Milestone: -

@mdh1418
Copy link
Member Author

mdh1418 commented Jan 11, 2024

/azp run runtime-extra-platforms

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mdh1418
Copy link
Member Author

mdh1418 commented Jan 11, 2024

/azp run runtime-extra-platforms

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

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

LGTM

@mdh1418
Copy link
Member Author

mdh1418 commented Jan 11, 2024

Runtime failures are known, and runtime-extra-platforms failures are known/not related.

@mdh1418
Copy link
Member Author

mdh1418 commented Jan 11, 2024

Given that the latest commits were a matter of how AdvSimdEncode was excluded on Mono, I believe the test results wouldn't change from the previous run, and this PR is essentially excluding #95513 on Mono, so once LoadVector128x3AndUnzip is supported on Mono, this PR can be reverted.

@fanyang-mono @kunalspathak @tannergooding does excluding all of the code introduced by #95513 look good?
Hopefully LoadVector128x3AndUnzip will be supported soon before any possible additional calls to AdvSimdEncode are added, and even if they are, there will be a build error on Mono because of the guard around the entire method.

Copy link
Member

@fanyang-mono fanyang-mono left a comment

Choose a reason for hiding this comment

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

LGTM!

@mdh1418 mdh1418 merged commit 1a76e37 into dotnet:main Jan 12, 2024
174 of 178 checks passed
@mdh1418 mdh1418 deleted the skip_AdvSimdEncode_mono branch January 12, 2024 01:47
kunalspathak added a commit to kunalspathak/runtime that referenced this pull request Jan 13, 2024
kunalspathak added a commit that referenced this pull request Jan 16, 2024
* Revert "[libs] Skip AdvSimdEncode on Mono (#96829)"

This reverts commit 1a76e37.

* Revert "Use multi-reg load/store for EncodeToUtf8 (#95513)"

This reverts commit fdb03ca.

* Wrap load/store vector APIs in '#if false'

* Disable load/store vector tests

* remove the trailing space
tmds pushed a commit to tmds/runtime that referenced this pull request Jan 23, 2024
* [libs] Skip AdvSimdEncode on Mono

* Add guard around existing AdvSimdEncode callsite to exclude on Mono

* Add issue to guard

* Guard AdvSimdEncode logic for not Mono

* Make AdvSimdEncode inaccessible on Mono

* Update issue comment
tmds pushed a commit to tmds/runtime that referenced this pull request Jan 23, 2024
…#96944)

* Revert "[libs] Skip AdvSimdEncode on Mono (dotnet#96829)"

This reverts commit 1a76e37.

* Revert "Use multi-reg load/store for EncodeToUtf8 (dotnet#95513)"

This reverts commit fdb03ca.

* Wrap load/store vector APIs in '#if false'

* Disable load/store vector tests

* remove the trailing space
@github-actions github-actions bot locked and limited conversation to collaborators Feb 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants