Better L4 and array storage design
This commit is contained in:
@@ -31,33 +31,16 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Mathematics.Internal
|
||||
{
|
||||
[InlineArray(10)]
|
||||
internal unsafe struct MatrixIntrinsic
|
||||
{
|
||||
|
||||
private nint handle; //f32_panel_mul
|
||||
|
||||
public readonly nint this[
|
||||
MatrixIntrinsicHandle handle
|
||||
]
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => this[(int)handle];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal enum MatrixIntrinsicHandle : int
|
||||
{
|
||||
|
||||
BufferAdd = 0,
|
||||
BufferFill = 1,
|
||||
BufferScalarMul = 2,
|
||||
BufferSub = 3,
|
||||
BufferTranspose = 4,
|
||||
Add = 0,
|
||||
Fill = 1,
|
||||
ScalarMul = 2,
|
||||
Sub = 3,
|
||||
Transpose = 4,
|
||||
ClearPanel = 5,
|
||||
KerFma = 6,
|
||||
TileFma = 7,
|
||||
Fma = 6,
|
||||
Pivot = 8,
|
||||
|
||||
}
|
||||
@@ -66,18 +49,18 @@ namespace StgSharp.Mathematics.Internal
|
||||
public struct MatrixElementType
|
||||
{
|
||||
|
||||
public const int IntrinsicCount = 0xa;
|
||||
public const int IntrinsicCount = 0x0a;
|
||||
|
||||
public static readonly MatrixElementType F32 = new(0x00010004);
|
||||
public static readonly MatrixElementType F64 = new(0x00020008);
|
||||
public static readonly MatrixElementType I08 = new(0x00030001);
|
||||
public static readonly MatrixElementType I16 = new(0x00040002);
|
||||
public static readonly MatrixElementType I32 = new(0x00050004);
|
||||
public static readonly MatrixElementType I64 = new(0x00060008);
|
||||
public static readonly MatrixElementType U08 = new(0x00070001);
|
||||
public static readonly MatrixElementType U16 = new(0x00080002);
|
||||
public static readonly MatrixElementType U32 = new(0x00090004);
|
||||
public static readonly MatrixElementType U64 = new(0x000a0008);
|
||||
public static readonly MatrixElementType F32 = new(0x00000004);
|
||||
public static readonly MatrixElementType F64 = new(0x00010008);
|
||||
public static readonly MatrixElementType I08 = new(0x00020001);
|
||||
public static readonly MatrixElementType I16 = new(0x00030002);
|
||||
public static readonly MatrixElementType I32 = new(0x00040004);
|
||||
public static readonly MatrixElementType I64 = new(0x00050008);
|
||||
public static readonly MatrixElementType U08 = new(0x00060001);
|
||||
public static readonly MatrixElementType U16 = new(0x00070002);
|
||||
public static readonly MatrixElementType U32 = new(0x00080004);
|
||||
public static readonly MatrixElementType U64 = new(0x00090008);
|
||||
|
||||
[FieldOffset(0)] internal readonly int Mask;
|
||||
[FieldOffset(2)] public readonly ushort IntrinsicNode;
|
||||
@@ -96,14 +79,6 @@ namespace StgSharp.Mathematics.Internal
|
||||
|
||||
}
|
||||
|
||||
[InlineArray(MatrixElementType.IntrinsicCount)]
|
||||
internal unsafe struct MatrixIntrinsicArray
|
||||
{
|
||||
|
||||
private MatrixIntrinsic e0;
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal unsafe struct IntrinsicContext
|
||||
{
|
||||
@@ -112,7 +87,8 @@ namespace StgSharp.Mathematics.Internal
|
||||
public delegate* unmanaged[Cdecl]<int, ulong> factorial_simd; // factorial_simd
|
||||
public delegate* unmanaged[Cdecl]<char*, int, int, int> index_pair; // index_pair
|
||||
public delegate* unmanaged[Cdecl]<Vector4*, Vector4*, void> vec_f32_normalize_3; // f32_normalize_3
|
||||
public MatrixIntrinsicArray mat; // mat[4] in native order
|
||||
public MatrixMultiKernelIntrinsicArray mat_mk; // mat[4] in native order
|
||||
public MatrixSingleKernelIntrinsicArray mat_sk; // mat[4] in native order
|
||||
|
||||
public IntrinsicContext()
|
||||
{
|
||||
@@ -120,4 +96,79 @@ namespace StgSharp.Mathematics.Internal
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region mk
|
||||
|
||||
[InlineArray(10)]
|
||||
internal unsafe struct MatrixMultiKernelIntrinsic
|
||||
{
|
||||
|
||||
private nint handle; //f32_panel_mul
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void Call(
|
||||
MatrixIntrinsicHandle index,
|
||||
MatrixParallelTask* task
|
||||
)
|
||||
{
|
||||
nint ptr = this[(int)index];
|
||||
((delegate* unmanaged[Cdecl]<MatrixParallelTask*, void>)ptr)(task);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly nint Get(
|
||||
MatrixIntrinsicHandle index
|
||||
)
|
||||
{
|
||||
return this[(int)index];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[InlineArray(MatrixElementType.IntrinsicCount)]
|
||||
internal unsafe struct MatrixMultiKernelIntrinsicArray
|
||||
{
|
||||
|
||||
private MatrixMultiKernelIntrinsic e0;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region sk
|
||||
|
||||
[InlineArray(10)]
|
||||
internal unsafe struct MatrixSingleKernelIntrinsic
|
||||
{
|
||||
|
||||
private nint handle; //f32_panel_mul
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void Call(
|
||||
MatrixIntrinsicHandle index,
|
||||
MatrixKernel* left,
|
||||
MatrixKernel* right,
|
||||
MatrixKernel* ans,
|
||||
ulong scalar
|
||||
)
|
||||
{
|
||||
nint ptr = this[(int)index];
|
||||
((delegate* unmanaged[Cdecl]<MatrixKernel*, MatrixKernel*, MatrixKernel*, ulong, void>)ptr)(left,
|
||||
right,
|
||||
ans,
|
||||
scalar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[InlineArray(MatrixElementType.IntrinsicCount)]
|
||||
internal unsafe struct MatrixSingleKernelIntrinsicArray
|
||||
{
|
||||
|
||||
private MatrixSingleKernelIntrinsic e0;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user