Huge progress on Matrix Parallel, a parallel pool has its basic structure.
This commit is contained in:
@@ -31,16 +31,18 @@
|
||||
using StgSharp.HighPerformance;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace StgSharp.Mathematics
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public unsafe struct MatrixParallelTaskWrap
|
||||
public unsafe struct MatrixParallelTaskPackage
|
||||
{
|
||||
|
||||
[FieldOffset(0)] public MatrixKernel* left;
|
||||
@@ -85,4 +87,43 @@ namespace StgSharp.Mathematics
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public unsafe class MatrixParallelWrap
|
||||
{
|
||||
|
||||
public Queue<IntPtr>[] cache;
|
||||
|
||||
public MatrixParallelWrap(int wrapSize)
|
||||
{
|
||||
cache = new Queue<IntPtr>[wrapSize];
|
||||
for (int i = 0; i < cache.Length; i++) {
|
||||
cache[i] = new Queue<IntPtr>(8);
|
||||
}
|
||||
}
|
||||
|
||||
public Span<IntPtr> EnqueuePackage(Span<IntPtr> packageSpan)
|
||||
{
|
||||
int idx = 0;
|
||||
for (; idx < cache.Length; idx++) {
|
||||
cache[idx].Enqueue(packageSpan[idx]);
|
||||
}
|
||||
return packageSpan[idx..];
|
||||
}
|
||||
|
||||
public void EnqueuePackage(MatrixParallelTaskPackage* task)
|
||||
{
|
||||
Span<IntPtr> span = stackalloc IntPtr[cache.Length];
|
||||
MatrixParallelFactory.
|
||||
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool TryGetNextWrapTask(int idInWrap, out IntPtr handle)
|
||||
{
|
||||
return cache[idInWrap].TryDequeue(out handle);
|
||||
}
|
||||
|
||||
public record class Handle(int InWrapIndex, MatrixParallelWrap Wrap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user