L4 is now a burden
This commit is contained in:
@@ -40,88 +40,54 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace StgSharp.Mathematics.Numeric
|
namespace StgSharp.Mathematics.Numeric
|
||||||
{
|
{
|
||||||
internal unsafe interface IMatrixParallelQueue<TSelf> where TSelf : IMatrixParallelQueue<TSelf>
|
internal unsafe class MatrixParallelQueue : IDisposable
|
||||||
{
|
{
|
||||||
|
|
||||||
bool InitNumaPredictor(
|
private MatrixParallelTask[] _currentPack;
|
||||||
out IL4Predict predictor
|
private MatrixParallelTask[] _predictBuffer;
|
||||||
);
|
private bool disposedValue;
|
||||||
|
|
||||||
bool RequestTaskResource(
|
private int _currentCapacity;
|
||||||
MatrixParallelTask* task,
|
private int _cursor;
|
||||||
out L4CacheLine left,
|
private int _predictCapacity;
|
||||||
out L4CacheLine right,
|
|
||||||
out L4CacheLine ans
|
|
||||||
);
|
|
||||||
|
|
||||||
void ReturnTaskResource(
|
private ManualResetEventSlim _exchangeLock = new();
|
||||||
MatrixParallelTask* task,
|
|
||||||
in L4CacheLine left,
|
|
||||||
in L4CacheLine right,
|
|
||||||
in L4CacheLine ans
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
public MatrixParallelQueue()
|
||||||
|
|
||||||
internal interface IBufferQueueLeftRightAns : IMatrixParallelQueue<IBufferQueueLeftRightAns> { }
|
|
||||||
|
|
||||||
internal sealed unsafe class BufferQueueLeftRightAns_NoNuma : IMatrixParallelQueue<IBufferQueueLeftRightAns>
|
|
||||||
{
|
|
||||||
|
|
||||||
private MatrixParallelTask* _baseTask;
|
|
||||||
private readonly nuint _byteSize;
|
|
||||||
private readonly nuint _count;
|
|
||||||
private volatile nuint _cursor;
|
|
||||||
|
|
||||||
private volatile nuint _mat1;
|
|
||||||
private volatile nuint _mat2;
|
|
||||||
private volatile nuint _mat3;
|
|
||||||
|
|
||||||
private BufferQueueLeftRightAns_NoNuma() { }
|
|
||||||
|
|
||||||
internal BufferQueueLeftRightAns_NoNuma(
|
|
||||||
MatrixParallelTask* baseTask
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
_baseTask = baseTask;
|
_currentPack = new MatrixParallelTask[512];
|
||||||
_count = ((nuint)_baseTask->CommonX) * ((nuint)_baseTask->CommonY);
|
_predictBuffer = new MatrixParallelTask[512];
|
||||||
_byteSize = ((nuint)_baseTask->Mat1) + (((nuint)_baseTask->CommonX) * ((nuint)_baseTask->CommonY) * _baseTask->ElementType.Size);
|
|
||||||
|
|
||||||
|
|
||||||
_mat1 = (nuint)_baseTask->Mat1;
|
|
||||||
_mat2 = (nuint)_baseTask->Mat2;
|
|
||||||
_mat3 = (nuint)_baseTask->Mat3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InitNumaPredictor(
|
public void Dispose()
|
||||||
out IL4Predict predictor
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
predictor = null;
|
Dispose(disposing:true);
|
||||||
return false;
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe bool RequestTaskResource(
|
public bool TryGetTask(
|
||||||
MatrixParallelTask* task,
|
in MatrixParallelTask task
|
||||||
out L4CacheLine left,
|
|
||||||
out L4CacheLine right,
|
|
||||||
out L4CacheLine ans
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
left = new L4CacheLine(0, ref Unsafe.AsRef<int>(null), ref Unsafe.AsRef<int>(null));
|
if (_cursor >= _currentCapacity) {
|
||||||
right = new L4CacheLine(0, ref Unsafe.AsRef<int>(null), ref Unsafe.AsRef<int>(null));
|
return false;
|
||||||
ans = new L4CacheLine(0, ref Unsafe.AsRef<int>(null), ref Unsafe.AsRef<int>(null));
|
}
|
||||||
|
task = _currentPack[_cursor++];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe void ReturnTaskResource(
|
protected virtual void Dispose(
|
||||||
MatrixParallelTask* task,
|
bool disposing
|
||||||
in L4CacheLine left,
|
|
||||||
in L4CacheLine right,
|
|
||||||
in L4CacheLine ans
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return;
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing) {
|
||||||
|
_exchangeLock.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,6 +152,7 @@ namespace StgSharp.Mathematics.Numeric
|
|||||||
State = MatrixThreadState.Running;
|
State = MatrixThreadState.Running;
|
||||||
_managedThread.Priority = ThreadPriority.Highest;
|
_managedThread.Priority = ThreadPriority.Highest;
|
||||||
|
|
||||||
|
|
||||||
// MatrixParallelQueue taskQueue = BindedWrap.TaskQueue;
|
// MatrixParallelQueue taskQueue = BindedWrap.TaskQueue;
|
||||||
/*
|
/*
|
||||||
if (0 > (int)p ->ComputeHandle) {
|
if (0 > (int)p ->ComputeHandle) {
|
||||||
@@ -175,12 +176,12 @@ namespace StgSharp.Mathematics.Numeric
|
|||||||
|
|
||||||
#pragma warning disable CA5393
|
#pragma warning disable CA5393
|
||||||
[LibraryImport(Native.LibName, EntryPoint = "sn_get_simd_level_local")]
|
[LibraryImport(Native.LibName, EntryPoint = "sn_get_simd_level_local")]
|
||||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
|
||||||
internal static partial ulong GetSimdId();
|
internal static partial ulong GetSimdId();
|
||||||
|
|
||||||
[LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")]
|
[LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")]
|
||||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
|
||||||
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
|
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
|
||||||
private static unsafe partial void LoadIntrinsicFunction(
|
private static unsafe partial void LoadIntrinsicFunction(
|
||||||
IntrinsicContext* context,
|
IntrinsicContext* context,
|
||||||
|
|||||||
Reference in New Issue
Block a user