Mat mul mat is now on full function
This commit is contained in:
@@ -51,7 +51,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixParallelTaskPackage* nonGeneric = package;
|
||||
switch (nonGeneric->ComputeMode.OperationStyle)
|
||||
{
|
||||
case MatrixOperationStyle.BUFFER_INDEX:
|
||||
case MatrixIndexStyle.BUFFER_INDEX:
|
||||
return ScheduleBufferTask(nonGeneric);
|
||||
default:
|
||||
throw new InvalidOperationException($"Unknown mode {nonGeneric->ComputeMode.OperationStyle}.");
|
||||
@@ -110,80 +110,5 @@ namespace StgSharp.Mathematics.Numeric
|
||||
return handle;
|
||||
}
|
||||
|
||||
private static unsafe MatrixParallelHandle ScheduleKernelTask(
|
||||
MatrixParallelTaskPackage* package)
|
||||
{
|
||||
int primCount = package->PrimCount;
|
||||
int secCount = package->SecCount;
|
||||
int tileWidth = (1024 / secCount) + 1;
|
||||
int tileCount = (primCount + tileWidth - 1) / tileWidth;
|
||||
|
||||
MatrixParallelThread[] pool = LeadParallel(tileCount);
|
||||
/*
|
||||
if (pool.Length == 0)
|
||||
{
|
||||
// no need
|
||||
// LeadParallel has contained capacity check
|
||||
}
|
||||
/**/
|
||||
MatrixParallelHandle handle = new MatrixParallelHandle(pool);
|
||||
if (handle.Wraps.Length == 1)
|
||||
{
|
||||
handle.Wraps[0].WrapTask.Enqueue((nint)package);
|
||||
return handle;
|
||||
}
|
||||
int threadCount = pool.Length;
|
||||
int tilePerThreadLess = tileCount / threadCount; // tiles per thread without extra slice
|
||||
int columnAfterBaseTile = tileCount % threadCount * tileWidth; // tile sliced into columns
|
||||
int extraColumnPerThread = columnAfterBaseTile / threadCount;
|
||||
int extraColumnCount = columnAfterBaseTile % threadCount; // columns to be sliced
|
||||
|
||||
int total = primCount;
|
||||
MatrixParallelTaskPackage* current = package;
|
||||
foreach (MatrixParallelWrap wrap in handle.Wraps)
|
||||
{
|
||||
bool hasSlice = columnAfterBaseTile > 0;
|
||||
bool isLargeSlice = extraColumnCount > 0;
|
||||
|
||||
// _count tiles for wrap
|
||||
int wrapWidth = wrap!.WrapTaskCapacity/**/;
|
||||
int columnFromSlicingCount = (hasSlice ? extraColumnPerThread : 0) * wrapWidth;
|
||||
int baseColumn = wrapWidth * tilePerThreadLess * tileWidth;
|
||||
int columnInWrap = baseColumn + columnFromSlicingCount + (isLargeSlice ? 1 : 0);
|
||||
|
||||
// set tasks
|
||||
if (columnInWrap == 0)
|
||||
{
|
||||
#if DEBUG
|
||||
throw new InvalidOperationException("Zero tasks published.");
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
// update current task
|
||||
current->PrimColumnCountInTile = columnInWrap;
|
||||
current->SecColumnCountInTile = current->SecCount;
|
||||
current->SecTileOffset = 0;
|
||||
|
||||
// remove tiles _count
|
||||
extraColumnCount--;
|
||||
columnAfterBaseTile -= columnFromSlicingCount;
|
||||
total -= columnInWrap;
|
||||
|
||||
// set to wrap and push
|
||||
wrap.WrapTask.Enqueue((nint)current);
|
||||
|
||||
if (total <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
current = MatrixParallelFactory.FromExistPackage(current);
|
||||
current->PrimTileOffset += columnInWrap;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user