swiss ok, needs more benchmark

This commit is contained in:
Youmu Liu
2026-03-06 18:22:30 +08:00
parent 83997f64d0
commit f6e897ed06
70 changed files with 1889 additions and 3371 deletions
@@ -1,4 +1,4 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallel.Await"
// Project: StgSharp
@@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
@@ -43,7 +44,9 @@ namespace StgSharp.Mathematics.Numeric
private static volatile int _createGeneration = 0;
private static int _sortState;
public static MatrixParallelThread[] LeadParallel(int recommendCount)
public static MatrixParallelThread[] LeadParallel(
int recommendCount
)
{
int min = int.Min(recommendCount, _threads.Capacity);
min /= 2;
@@ -108,7 +111,9 @@ namespace StgSharp.Mathematics.Numeric
// return ret;
}
public static void ReturnParallelResources(ref MatrixParallelThread[] pool)
public static void ReturnParallelResources(
ref MatrixParallelThread[] pool
)
{
while (true)
{
@@ -123,7 +128,11 @@ namespace StgSharp.Mathematics.Numeric
pool = null!;
}
private record class WaitHandle(int generation, int least, int best)
private record class WaitHandle(
int generation,
int least,
int best
)
{
public int CreateGeneration { get; init; } = generation;
@@ -135,7 +144,9 @@ namespace StgSharp.Mathematics.Numeric
public int Priority { get; private set; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void UpdatePriority(int currentGeneration)
public void UpdatePriority(
int currentGeneration
)
{
Priority = (currentGeneration - CreateGeneration) * (MatrixParallel._threads.Capacity - LeastCount);
}