You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[mono] Pass Vector64, Vector128, and Vector256 in SIMD registers whenever possible #60068
A related issue #9578 is tracking the CoreCLR work to unblock passing Vector128/Vector256 by value to P/Invokes. It's currently blocked (with a bad error message about the types not being blittable) due to CoreCLR incorrectly marshalling vector return values on Windows x64.
A related issue is for CoreCLR to implement support for __vectorcall on Windows #8300
A specific use-case is to be able to call Apple platform APIs that have some arguments that have types with a __ext_vector_type attribute. (see the Mono issue linked above)
When using LLVM as codegen backend, LLVM is able to does the work of sending the data to SIMD register before the operation. Here is an example from x64
c# code
using System;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.CompilerServices;
using System.Numerics;
namespace HelloWorld
{
internal class Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
private static Vector128<int> test(Vector128<int> a, Vector128<int> b, Vector128<int> c)
{
return Vector128.Min(a,b);
}
private static void Main(string[] args)
{
Vector128<int> A = Vector128.Create((int)3.1);
Vector128<int> B = Vector128.Create((int)5.7);
Vector128<int> C = Vector128.Create((int)50);
var result = test(A, B, C);
Console.WriteLine(result);
}
}
}
making managed-to-managed calls utilize a calling convention where those Vector128<int> arguments oculd be passed in SIMD registers directly (so those movs aren't needed - the arguments would already be in %xmm0 and `%xmm1).
These two problems could be tackled separately: we could just do the managed-to-managed calls first. But we would still need to do something for LLVM (as your example shows)
Activity
lambdageek commentedon Oct 6, 2021
Would allow us to run these tests https://github.com/dotnet/runtime/tree/main/src/tests/Interop/PInvoke/Generics and implement mono/mono#17868
A related issue #9578 is tracking the CoreCLR work to unblock passing Vector128/Vector256 by value to P/Invokes. It's currently blocked (with a bad error message about the types not being blittable) due to CoreCLR incorrectly marshalling vector return values on Windows x64.
A related issue is for CoreCLR to implement support for
__vectorcallon Windows #8300lambdageek commentedon Oct 6, 2021
A specific use-case is to be able to call Apple platform APIs that have some arguments that have types with a
__ext_vector_typeattribute. (see the Mono issue linked above)lambdageek commentedon Oct 6, 2021
We would need this across the board: LLVM, mini and interp should support it.
fanyang-mono commentedon Apr 20, 2022
When using LLVM as codegen backend, LLVM is able to does the work of sending the data to SIMD register before the operation. Here is an example from x64
c# code
When LLVM is enabled:
Thus, this work actually only apply to mini and interp.
lambdageek commentedon Apr 21, 2022
@fanyang-mono
In your example see how the arguments are actually passed in
%rdxand%rsiand then moved into%xmm0and%xmm1:What this issue is about is two things:
Vector128<int>arguments oculd be passed in SIMD registers directly (so those movs aren't needed - the arguments would already be in%xmm0and `%xmm1).These two problems could be tackled separately: we could just do the managed-to-managed calls first. But we would still need to do something for LLVM (as your example shows)
fanyang-mono commentedon Apr 21, 2022
Gotcha!
fanyang-mono commentedon Aug 2, 2022
Nice to have, moving to 8.0.0
fanyang-mono commentedon Jul 12, 2023
This is a tracking issue. Moving it to .NET9.
lewing commentedon Feb 9, 2024
cc @steveisok @vargaz