matrix parallel start to use two different policy

This commit is contained in:
Youmu Liu
2026-04-27 20:08:10 +08:00
parent ecb1f04770
commit ae664cb541
16 changed files with 170 additions and 239 deletions
@@ -39,18 +39,96 @@ using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
{
internal unsafe class MatrixParallelQueue<TPredictor>
where TPredictor : class, IMatrixCachePredictor<TPredictor>
internal unsafe interface IMatrixParallelQueue<TSelf> where TSelf : IMatrixParallelQueue<TSelf>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool Steal(
MatrixParallelTask* task
static abstract bool NeedNumaBuffer { get; }
static abstract TSelf Create(
MatrixParallelTask* baseTask,
L4 buffer
);
void Return(
MatrixParallelTask* task
);
bool Steal(
MatrixParallelTask* task
);
}
internal sealed unsafe class BufferSequentialQueue : IMatrixParallelQueue<BufferSequentialQueue>
{
private MatrixParallelTask* baseTask;
private BufferSequentialQueue() { }
private BufferSequentialQueue(
MatrixParallelTask* baseTask
)
{
this.baseTask = baseTask;
}
public static bool NeedNumaBuffer => throw new NotImplementedException();
public static unsafe BufferSequentialQueue Create(
MatrixParallelTask* baseTask,
L4 buffer
)
{
return new BufferSequentialQueue(baseTask);
}
public unsafe void Return(
MatrixParallelTask* task
) { }
public unsafe bool Steal(
MatrixParallelTask* task
)
{
// TODO 使用提取的内容填充task
throw new NotImplementedException();
}
private class Predictor : IL4Predict
{
public PredictResult Predict(
Span<CacheLineDescription> node,
out int count
)
{
throw new NotImplementedException();
}
public void Prefetch(
nuint origin,
uint policy,
Span<byte> cache
)
{
throw new NotImplementedException();
}
public void WriteBack(
nuint origin,
uint policy,
ReadOnlySpan<byte> cache
)
{
MatrixCachePolicy pEnum = (MatrixCachePolicy)policy;
if ((pEnum & (MatrixCachePolicy.Ans | MatrixCachePolicy.Sequential)) != 0)
{
byte* span = (byte*) origin;
cache.CopyTo(new Span<byte>(span, cache.Length));
}
}
}
}
}