Daily update on 20250907-184649 by Nitload Youmu. Additional Message : Matrix parallel task packet is done, parallel task executer is done. Now is working on building parallel wrap and pool.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -37,69 +37,95 @@ using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.Mathematics
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 32, Pack = 8)]
|
||||
public unsafe struct MatrixParallelEnumeration
|
||||
public unsafe struct ScalarPacket
|
||||
{
|
||||
|
||||
[FieldOffset(00)] public MatrixKernel* kernel;
|
||||
private fixed ulong data[8];
|
||||
|
||||
[FieldOffset(08)] public int begin;
|
||||
[FieldOffset(12)] public int end;
|
||||
[FieldOffset(16)] public int offset;
|
||||
[FieldOffset(20)] public int primStride;
|
||||
[FieldOffset(24)] public int secStride;
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = 128, Pack = 8)]
|
||||
public unsafe struct MatrixParallelTaskPackage
|
||||
{
|
||||
|
||||
[FieldOffset(0)] public MatrixKernel* Left;
|
||||
[FieldOffset(24)] public MatrixKernel* Result;
|
||||
[FieldOffset(48)] public MatrixKernel* Right;
|
||||
[FieldOffset(72)] public ScalarDataPacket* scalerPacket;
|
||||
[FieldOffset(80)] public int ComputeMode;
|
||||
[FieldOffset(84)] public int primCount;
|
||||
[FieldOffset(88)] public int secCount;
|
||||
[FieldOffset(108)] public IntPtr executionHandle;
|
||||
|
||||
[FieldOffset(0)] public MatrixParallelEnumeration LeftEnum;
|
||||
[FieldOffset(24)] public MatrixParallelEnumeration ResultEnum;
|
||||
[FieldOffset(48)] public MatrixParallelEnumeration RightEnum;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scalar data packet for storing up to 8 parameters as type-erased ulong values Supports
|
||||
/// reference counting for shared usage across multiple tasks Used to separate scalar data
|
||||
/// allocation from task allocation and track batch completion
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 72)]
|
||||
public unsafe struct ScalarDataPacket
|
||||
{
|
||||
|
||||
public const int MaxScalarCount = 8;
|
||||
public const int PacketSize = 64;
|
||||
|
||||
[FieldOffset(0)] private fixed ulong Value[8];
|
||||
|
||||
public ScalarDataPacket()
|
||||
public ref T Data<T>(int index) where T: unmanaged,INumber<T>
|
||||
{
|
||||
Unsafe.SkipInit(out this);
|
||||
}
|
||||
|
||||
public ref T GetScalerRef<T>(int index) where T: unmanaged, INumber<T>
|
||||
{
|
||||
if (index is < 0 or >= MaxScalarCount) {
|
||||
throw new IndexOutOfRangeException("ScalarDataPacket index out of range");
|
||||
if (index is < 0 or >= 8) {
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
return ref Unsafe.As<ulong, T>(ref Value[index]);
|
||||
|
||||
return ref Unsafe.As<ulong, T>(ref data[index]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal unsafe struct MatrixParallelTaskPackage
|
||||
{
|
||||
|
||||
#region source
|
||||
|
||||
// Group 1: Left/Right matrix kernel base address
|
||||
public MatrixKernel* Left; // 8
|
||||
public MatrixKernel* Right; // 8
|
||||
|
||||
#endregion
|
||||
|
||||
#region ans
|
||||
|
||||
// Group 2: Result kernel base address + reserved
|
||||
public MatrixKernel* Result; // 8
|
||||
public void* ReservedPtr0; // 8 (extension/reserved)
|
||||
|
||||
#endregion
|
||||
|
||||
#region left enum
|
||||
|
||||
public int LeftPrimOffset; // 4
|
||||
public int LeftPrimStride; // 4
|
||||
public int LeftSecOffset; // 4
|
||||
public int LeftSecStride; // 4
|
||||
|
||||
#endregion
|
||||
|
||||
#region right enum
|
||||
|
||||
public int RightPrimOffset; // 4
|
||||
public int RightPrimStride; // 4
|
||||
public int RightSecOffset; // 4
|
||||
public int RightSecStride; // 4
|
||||
|
||||
#endregion
|
||||
|
||||
#region ans enum
|
||||
|
||||
public int ResultPrimOffset; // 4
|
||||
public int ResultPrimStride; // 4
|
||||
public int ResultSecOffset; // 4
|
||||
public int ResultSecStride; // 4
|
||||
|
||||
#endregion
|
||||
|
||||
#region scalar/compute
|
||||
|
||||
public ScalarPacket* Scalar; // 8
|
||||
public IntPtr ComputeHandle; // 8
|
||||
|
||||
#endregion
|
||||
|
||||
#region global profile
|
||||
|
||||
public int PrimCount; // 4
|
||||
public int ComputeMode; // 4
|
||||
public int SecCount; // 4
|
||||
private readonly int ReservedInt0; // 4
|
||||
|
||||
#endregion
|
||||
|
||||
#region reserve
|
||||
|
||||
public long ReservedLong0; // 8
|
||||
public long ReservedLong1; // 8
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user