What is the rationale for Vector128.ConvertToDouble
having a codepath for SSE2 in C#?
#111195
-
I notice that the implementation of But (as far as I can tell) this method also has JIT support: My question is: why does the
I'm really interested in the rationale behind this. (I'm interested in the general pattern for all cross-platform SIMD intrinsic APIs, but it seemed better to frame this as a question about this specific API. I'd guess that the answer may be similar for the general case.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For x64, this is notably only done when
Not all code is trivial to implement in the JIT, due to the size of the IR required to be inserted. In the case of Sometimes, particularly for methods where it isn't critical to have it done in the JIT we instead do it in managed for simplicity. In many cases its just point in time and it would be possible to add a path to the JIT instead, it just hasn't been a high enough priority.
Some APIs are simply not possible to implement in C#. Which is to say, the various Additionally, the foundational APIs are generally considered "perf critical" and are often used very densely together. Because of this, we'd end up seeing non-trivial impact to JIT compilation throughput and likely some minor code artifacts if every single one of these APIs, which often compile down to 1 single instruction, had to instead first have the IL for 3-4 architectures each with 1-5 ISAs inlined, had to then have the dead code paths eliminated (which is the majority of them), had to have the branches removed and rationalized to be the single IR node, and then finish the compilation. So these foundational APIs are instead marked |
Beta Was this translation helpful? Give feedback.
For x64, this is notably only done when
Avx512F
orAvx10v1
is available. This fallsback to the managed implementation for hardware with only[SSE2, AVX2]
supportNot all code is trivial to implement in the JIT, due to the size of the IR required to be inserted. In the case of
ConvertToDouble
, there are 7-9 IR nodes that need to be inserted for this operation.Sometimes, particularly for methods where it isn't critical to have it done in the JIT we instead do it in managed for simplicity. In many cases its just point in time and it would be possible to add a path to the…