-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numerics
Milestone
Description
At the 2019 MVP Summit, I got some level of feedback that we do not currently have a zero-cost mechanism for converting between the various System.Numerics.Vector types and the System.Runtime.Intrinsic vector types.
We should come up with an API proposal to make this conversion process non-expensive.
- For types like
Vector4 <-> Vector128<float>this should be true zero-cost. - For types like
Vector2orVector3this should be zero-cost if the type is either already in register or if it was spilled to the stack as aTYP_SIMD16. Vector<T>is a bit more troublesome given that it is dynamically sized.
Proposed API
// Vector2, Vector3, and Vector4 will be moved down to S.P.Corelib
namespace System.Runtime.Intrinsics
{
public static partial class Vector128
{
// Converting to intrinsic types
public static Vector128<float> AsVector128(this Vector2 value);
public static Vector128<float> AsVector128(this Vector3 value);
public static Vector128<float> AsVector128(this Vector4 value);
public static Vector128<T> AsVector128<T>(this Vector<T> value) where T : struct;
// Converting from intrinsic types
public static Vector2 AsVector2(this Vector128<float> value);
public static Vector3 AsVector3(this Vector128<float> value);
public static Vector4 AsVector4(this Vector128<float> value);
public static Vector<T> AsVector<T>(this Vector128<T> value) where T : struct;
}
public static partial class Vector256
{
// Converting to intrinsic types
public static Vector256<T> AsVector256<T>(this Vector<T> value) where T : struct;
// Converting from intrinsic types
public static Vector<T> AsVector<T>(this Vector256<T> value) where T : struct;
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numerics