-
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
Add a number of additional APIs to the various SIMD accelerated vector types #111179
base: main
Are you sure you want to change the base?
Conversation
Note regarding the
|
Note regarding the
|
c44246f
to
d9bd816
Compare
CC. @dotnet/jit-contrib there's some JIT side changes for review/approval here The summary of changes is:
I added support for the new |
@jkurdek could you please review the mono parts? Do we need to update other codegens for this as well? |
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.
Currently this change doesn't implement the new APIs on mono side, it just reverts to managed. @tannergooding do you plan to bring those in to mono in this PR?
@@ -6525,6 +6562,10 @@ emit_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi | |||
MonoInst* | |||
mono_emit_simd_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) | |||
{ | |||
if (!has_intrinsic_cattr (cmethod)) { |
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.
I'm not sure what the impact of this is going to be. if we had some intrinsics for methods which weren't marked [Intrinsic]
before now they gonna experience slow downs. Have you benchmarked this one?
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 makes it match the behavior that RyuJiT has. Anything that isn’t marked Intrinisic is not intended to be handled as such and is likely a Mono bug
If, after merge, there are regressions then we should look at those cases individually and determine if the attribute should be added.
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.
Mono may have had intrinsics for a few non-Intrinsic methods previously for performance reasons, but I think it's valid to do this and see how it shakes out as long as we pay attention to the benchmarks.
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.
Mono may have had intrinsics for a few non-Intrinsic methods previously for performance reasons
👍 We should definitely make sure such cases are known and mark them as [Intrinsic]
in those scenarios instead. It massively simplifies things and should also improve Mono throughput, as we won't be doing unnecessary work for every single API anymore.
If it's truly unique to Mono, then we can even do the following; however I expect most places that Mono handles should also be handled on RyuJIT or at least get the inlining profitability boost from the attribute:
#if MONO
[Intrinsic]
#endif
Assuming this PR is merged before the weekend, we should catch any such regressions next Tuesday and be able to trivially root cause the smaller number of samples so we can know what should be attributed.
-- Notably this is being done in this PR for correctness reasons; there are cases where Mono has "bad assumptions" about signatures and where it was trying to treat an API named X
as an intrinsic for X
, even when the signature is a different overload all together and was designed to mean something different. This was the case for some APIs like Vector.Store
which exposes extension methods for Vector<T>
and also Vector2/3/4
as an example.
It implements a few, but not all of them. I plan on finishing up the other new For the other APIs, they would be handled at the same time as support is added to RyuJIT, which as per the top post is not being done yet. |
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.Extensions.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.Extensions.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs
Show resolved
Hide resolved
Happy to see a lot of these additions, should cut down on the amount of per-architecture code necessary to solve problems. |
I've added handling in a few more cases where it is trivial to do so. However, there are still a couple of the helpers that are not so trivial to do in this PR. Namely we're missing a centralized helper for some concepts like -- Such internal helpers is notably what the |
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.
LGTM (non-Mono parts), although, it seems like managed implementations for these new APIs are trivial enough (for integers) to stay managed only?
Potentially. But there was also pushback when I had previously tried to move all the code, whether trivial or not, into managed. We had essentially decided at that time that cases that are trivial to handle in the JIT and which are expected to be fairly typical should be done in the JIT; which is why most of the paths were added for the The |
This resolves #103845 and #98055