[Mono] [Arm64] Add basic Vector3 SIMD intrinsics#97416
Conversation
|
Tagging subscribers to this area: @SamMonoRT, @fanyang-mono Issue DetailsBasic SIMD support for System.Numerics.Vector3. Should fix #91456
|
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Probably needs llvm support as well. |
a0aa8fe to
1e30142
Compare
|
The llvm changes look ok as well, just the formatting needs to be cleaned up to conform to the mono coding convs. |
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
src/mono/mono/mini/mini-llvm.c
Outdated
|
|
||
| if (mono_class_value_size (klass, NULL) == 12) | ||
| len--; |
There was a problem hiding this comment.
Why are we decrementing len here?
There was a problem hiding this comment.
I encountered case that lhs would be V3 represented as V4(three elements + zero). And the retval would be V3.
The code tried to extract the fourth value of lhs and insert it into retval which caused an error, as retval had only three elements.
The change made it only extract and insert the first three elms if V3 was encoutered
There was a problem hiding this comment.
I would add comment explaining this special case for easier comprehension.
There was a problem hiding this comment.
@jkurdek thank you for the explanation.
Just for my understanding, so it basically means that in such cases LLVMGetReturnType (ctx->lmethod_type) and LLVMTypeOf (lhs) are returning a different type (as we end up having different vector sizes) ?
If we have these kind of workarounds across the mini-llvm code, I think it is ok to manually adjust the len however to be less cryptic, it might be better to have a comment explaining the special-casing (as @matouskozak suggested) and something like this instead:
// TODO: Here add explanation why handling Vector3 requires special treatment
int len = mono_class_value_size (klass, NULL) == 12 ? 3 : LLVMGetVectorSize (LLVMTypeOf (lhs));There was a problem hiding this comment.
Yup, LLVMGetReturnType (ctx->lmethod_type) is a vector of three elements, whereas LLVMTypeOf (lhs) is a vector of four elements (three + zero)
There was a problem hiding this comment.
Since 3 element vectors don't exist in the hardware, it might be easier to use 4 elements ones in return types etc. and only handle 3 element ones in loads/stores etc.
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Test failures seem unrelated |
matouskozak
left a comment
There was a problem hiding this comment.
The changes look good to me, as a follow up we could intrisify more Vector3/4 constructors.
| for (int i = 1; i < fsig->param_count; ++i) | ||
| ins = emit_vector_insert_element (cfg, klass, ins, MONO_TYPE_R4, args [i + 1], i, FALSE); | ||
|
|
||
| if (len == 3) { |
There was a problem hiding this comment.
Does this also handle the Vector3 constructor: Vector3 (Vector2, float)? As a follow up we could enable this block
runtime/src/mono/mono/mini/simd-intrinsics.c
Lines 2734 to 2762 in 93381bf
There was a problem hiding this comment.
It is not supported yet, I created a new issue for the rest of vector constructors as it seems they don't work out of the box.
src/mono/mono/mini/mini-llvm.c
Outdated
|
|
||
| if (mono_class_value_size (klass, NULL) == 12) | ||
| len--; |
There was a problem hiding this comment.
I would add comment explaining this special case for easier comprehension.
Co-authored-by: Ivan Povazan <[email protected]>
Basic SIMD support for System.Numerics.Vector3. Should fix #91456