matrix parallel start to use two different policy
This commit is contained in:
@@ -84,7 +84,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
_retiredThreads = new(RESERVED_THREAD_COUNT);
|
||||
|
||||
// init thread on all logical cores
|
||||
MatrixParallelThread[][] numaWaveOrigin = Numa.CreateForeachThread<MatrixParallelThread>(
|
||||
_numaWaveFront = Numa.CreateForeachThread<MatrixParallelThread>(
|
||||
core => {
|
||||
MatrixParallelThread thread = new(core);
|
||||
SpinWait.SpinUntil(() => thread.State == MatrixThreadState.Ready);
|
||||
@@ -108,15 +108,15 @@ namespace StgSharp.Mathematics.Numeric
|
||||
// retire threads
|
||||
if (ContextCount == 1)
|
||||
{
|
||||
MatrixParallelThread[] threadArr = numaWaveOrigin[0];
|
||||
MatrixParallelThread[] threadArr = _numaWaveFront[0];
|
||||
int retireCount = Math.Min(RESERVED_THREAD_COUNT, Math.Max(0, threadArr.Length));
|
||||
for (int i = 1; i <= retireCount; i++) {
|
||||
RetireThread(threadArr[^i]);
|
||||
}
|
||||
_numaWaveFront[0] = [.. threadArr[0..^retireCount]];
|
||||
_numaWaveFront[0] = threadArr[0..^retireCount];
|
||||
} else
|
||||
{
|
||||
RetireWhenMultipleSIMDID(numaWaveOrigin);
|
||||
RetireWhenMultipleSIMDID(_numaWaveFront);
|
||||
}
|
||||
_meaningful = _threads.Length > 1;
|
||||
|
||||
@@ -151,7 +151,6 @@ namespace StgSharp.Mathematics.Numeric
|
||||
) => CompareSIMDID(left.Simd, right.Simd));
|
||||
int retireCount = Math.Min(RESERVED_THREAD_COUNT, Math.Max(0, allThreads.Length));
|
||||
|
||||
// HashSet<MatrixParallelThread> retiredSet = [];
|
||||
MatrixParallelThread[] retireArr = new MatrixParallelThread[retireCount];
|
||||
for (int i = 0; i < retireCount; i++)
|
||||
{
|
||||
@@ -183,7 +182,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
}
|
||||
|
||||
_numaWaveFront[numa] = [.. active];
|
||||
_numaWaveFront[numa] = active;
|
||||
}
|
||||
|
||||
_threads = allThreads[retireCount..];
|
||||
|
||||
Reference in New Issue
Block a user