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