no progress in matrix parallel
This commit is contained in:
@@ -35,60 +35,41 @@ using System.Drawing;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.Mathematics
|
||||
{
|
||||
/// <summary>
|
||||
/// Matrix parallel computation task structure with scalar data packet support Uses type-
|
||||
/// erased design for thread pool compatibility
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 48)]
|
||||
public unsafe struct MatrixParallelTask
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public unsafe struct MatrixParallelTaskWrap
|
||||
{
|
||||
|
||||
public const int SizeofConstantParameter = sizeof(ulong);
|
||||
public const int SizeOfTask = 48;
|
||||
|
||||
[FieldOffset(0)] public MatrixKernel* left;
|
||||
[FieldOffset(8)] public MatrixKernel* result;
|
||||
[FieldOffset(16)] public MatrixKernel* right;
|
||||
[FieldOffset(24)] public int scalerCount;
|
||||
[FieldOffset(40)] public ScalarDataPacket* scalerPacket;
|
||||
[FieldOffset(24)] public int ComputeMode;
|
||||
[FieldOffset(60)] public int count;
|
||||
|
||||
[FieldOffset(48)] public int leftStride;
|
||||
[FieldOffset(56)] public int resultStride;
|
||||
[FieldOffset(52)] public int rightStride;
|
||||
[FieldOffset(32)] public IntPtr executionHandle;
|
||||
|
||||
/// <summary>
|
||||
/// Pointer to the scalar data packet containing up to 8 parameters Each parameter is
|
||||
/// stored as ulong (8 bytes) for type erasure
|
||||
/// </summary>
|
||||
[FieldOffset(40)] public nint scalerDataPacket;
|
||||
|
||||
/// <summary>
|
||||
/// Execute the task using type-erased function pointer
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly void Execute()
|
||||
{
|
||||
if (scalerCount == 0)
|
||||
{
|
||||
((delegate*<MatrixKernel*, MatrixKernel*, MatrixKernel*, void>)executionHandle)(left, right, result);
|
||||
} else
|
||||
{
|
||||
((delegate*<MatrixKernel*, MatrixKernel*, MatrixKernel*, void*, void>)executionHandle)(left, right, result, (void*)scalerDataPacket);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scalar data packet for storing up to 8 parameters as type-erased ulong values Used to
|
||||
/// separate scalar data allocation from task allocation
|
||||
/// 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;
|
||||
|
||||
private fixed ulong Value[8];
|
||||
[FieldOffset(0)] private fixed ulong Value[8];
|
||||
|
||||
public ScalarDataPacket()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user