-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Optimize Vector.Max codegen using AVX512 #116117
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
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Changes generally LGTM, there was just a simplification to There's likely an opportunity to share the general logic between the |
c97b569
to
e708325
Compare
CC. @dotnet/jit-contrib, @EgorBo for secondary sign-off. |
These Min and Max routines look like they can be unified to remove the code duplication: https://www.diffchecker.com/SYTwWTzO/ |
Right. They are unified for the scalar path already too. I think when we finish the factoring to also accelerate |
@alexcovington is also covering the other Min/Max APIs listed something you'd be interested in doing? If not, I can get something up over the weekend handling them. |
I'm not sure it's something I can commit to right now. It is probably better to assign the other variants to someone else for now. |
No worries, I can get to it. Thanks for the improvements made here!! |
Thanks so much for the feedback and review @tannergooding and @EgorBo! |
This PR optimizes the codegen for
Vector128/256/512.Max
andVector128/256/512.Min
when AVX512 is supported. The new codegen emitted is the same pattern as the scalar codegen forMath.Max
/Math.Min
.Scalar version + codegen
Vector Max version + codegen
Codegen (before):
Codegen (after):
Vector Min version + codegen
Codegen (before):
Codegen (after):
Performance
These are the existing Max microbenchmarks for System.Numerics.Tensors:
There were not any equivalent Min benchmarks, so I copied the existing Max microbenchmarks and modified them to use Min: