Uh oh!
There was an error while loading. Please reload this page.
Update Mono to handle various other vector bitcast APIs - #104049
Update Mono to handle various other vector bitcast APIs#104049tannergooding wants to merge 1 commit into
Conversation
Tagging subscribers to this area: @steveisok, @lambdageek |
Uh oh!
There was an error while loading. Please reload this page.
kg
commented
Jun 26, 2024
At a glance this all looks good. If the regression still isn't gone after this on wasm, I can help implement the new intrinsics in the jiterpreter. |
I'm not sure why The mono interp handling for |
steveisok
commented
Jun 26, 2024
#104028 should make it better. All ios/tvos device runs were failing before this. |
tannergooding
commented
Jun 26, 2024
Glad to know it wasn't something on my end, hopefully this is green and can get merged as it should give us some nice improvements 🎉 |
3d8a019 to
434ff3dCompare| static gboolean | ||
| get_common_simd_info (MonoClass *vector_klass, MonoMethodSignature *csignature, MonoTypeEnum *atype, int *vector_size, int *arg_size, int *scalar_arg) | ||
| get_common_simd_info (MonoClass *klass, MonoTypeEnum *atype, int *klass_size, int *arg_size) |
There was a problem hiding this comment.
This file ended up needing a bit of a refactoring as there were some assumptions in place that don't hold when supporting additional intrinsics.
In particular, there are various intrinsics where:
- one of the SIMD types may not be generic at all (
Vector2,Vector3,Vector4) - multiple generic types exist (
As<TFrom, TTo>) - the return type may not be a 128-bit vector (
AsVector2,AsVector3)
So, what I did here was I broke this get_common_simd_info method into two:
get_common_simd_infoget_common_simd_scalar_arg
The former now always gets the size of the input klass and secondly determines if it is a SIMD type and what the underlying element type is if so. While the latter identifies the first non-SIMD argument, if one exists.
| static void | ||
| emit_common_simd_epilogue (TransformData *td, MonoClass *vector_klass, MonoMethodSignature *csignature, int vector_size, gboolean allow_void) | ||
| emit_common_simd_epilogue (TransformData *td, MonoMethodSignature *csignature) |
There was a problem hiding this comment.
To support methods which return a value type, but where that isn't a 128-bit vector, this explicitly gets the return type from the signature to ensure there can be no accidents
| gint16 simd_intrins = -1; | ||
| vector_klass = mono_class_from_mono_type_internal (csignature->ret); | ||
| MonoTypeEnum ret_atype; |
There was a problem hiding this comment.
In here, we consistently query the relevant simd information of the return type and if it exists the simd information of the first parameter (this is enough to correctly handle all the cases that currently exist).
There's actually quite a bit of logic in this function that could be moved down into emit_common_simd_operations, as APIs like AndNot exist for Vector128<T> and Vector<T>, they may also exist for types like Vector4 in the future. I opted to not move that down in this PR, to try and keep the total churn under control.
But, I did add some basic validation that the encountered signatures are roughly as expected to help ensure we don't hit issues in the future as new overloads are introduced or the general SIMD support in Mono is expanded.
742333c to
f35dd63Comparef35dd63 to
4cd5d90Compare4cd5d90 to
e4a14fbCompare09ee415 to
1d03cbdCompare1d03cbd to
8b0b476Comparetannergooding
commented
Jun 28, 2024
Similarly to #103915, I don't have the time to continue to try and debug why these changes aren't working for Mono. Anyone should feel free to pick this up if they have more context or time. -- As it stands, there appears to be some quirk where Mono is either incorrectly doing comparisons or other handling around |
This should resolvedotnet/perf-autofiling-issues#36484