Merge from branch giga

This commit is contained in:
Nitload
2025-08-31 10:42:51 +08:00
parent 1fc687f7d0
commit 1a0ccdd8cb
1619 changed files with 2812 additions and 733136 deletions
+15 -32
View File
@@ -32,6 +32,7 @@ using StgSharp.Collections;
using StgSharp.Controlling.UsrActivity;
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.HighPerformance;
using StgSharp.HighPerformance.Memory;
using StgSharp.Mathematics;
using StgSharp.Model.Step;
@@ -56,44 +57,25 @@ namespace StgSharp
internal static unsafe void Main(string[] args)
{
World.Init();
/**/
try
{
World.Init();
HybridLayerSegregatedFitAllocator hlsf = new HybridLayerSegregatedFitAllocator(64 * 400 * 400);
// HLSF test arena
Console.WriteLine(
"=== HLSF (Hybrid Layer Segregated Fit Allocator) Test Arena ===\n");
HybridLayerSegregatedFitAllocator hlsfAllocator = new HybridLayerSegregatedFitAllocator(1024 * 1024);
Stack<HybridLayerSegregatedFitAllocationHandle> handles = [];
Matrix<float> m = Matrix<float>.FromHlsf(400, 200, hlsf);
hlsfAllocator.DisplayEntryLayout(false);
for (int c = 0; c < 1; c++)
int i = 0, ii = 0;
foreach (Matrix<float>.Segment lines in m.GetRowEnumeration())
{
int i = 0;
for (; i < 1024 * 1024 / 1024; i++)
i = 0;
foreach (MatrixKernel* item in lines)
{
Console.WriteLine($"{c} cycles: Allocating the {i}th block.");
handles.Push(hlsfAllocator.Alloc(1024));
hlsfAllocator.DisplayEntryLayout(true);
Console.ReadKey();
i++;
Console.WriteLine(i);
}
Console.WriteLine($"{i} allocs called, {handles.Count} handles collected.");
Console.ReadKey();
while (handles.TryPop(out HybridLayerSegregatedFitAllocationHandle h))
{
i--;
hlsfAllocator.Free(h);
Console.WriteLine($"{c} cycles: The {i}th handle is freed");
}
if (handles.Count != 0)
{
Console.WriteLine($"[警告] 第{c}轮后Stack未清空,剩余{handles.Count}个handle未释放!");
} else
{
Console.WriteLine("All handles freed.");
}
Console.ReadKey();
ii++;
Console.WriteLine($"============================{ii}");
}
}
catch (Exception ex)
@@ -111,7 +93,8 @@ namespace StgSharp
{
World.Terminate(0);
}
/**/
}
}
}
}