daily commit on 0917

This commit is contained in:
Youmu Liu
2025-09-17 20:39:27 +08:00
parent 9312407b0f
commit 6e27c6219d
3 changed files with 47 additions and 5 deletions
@@ -28,19 +28,33 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.HighPerformance;
using StgSharp.HighPerformance.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using hlsfAllocator = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
namespace StgSharp.Mathematics
{
internal static unsafe class MatrixParallelFactory
{
private static hlsfAllocator _intermediateResult;
private static
#if NET9_0_OR_GREATER
Lock
#else
object
#endif
_hlsfLock = new();
private static SlabAllocator<ScalarPacket> _scalarAllocator ;
private static SlabAllocator<MatrixParallelTaskPackage> _wrapAllocator ;
@@ -49,6 +63,8 @@ namespace StgSharp.Mathematics
public static MatrixParallelTaskPackage* CreateBaseTask()
{
MatrixParallelTaskPackage* p = (MatrixParallelTaskPackage*)_wrapAllocator.Allocate();
Span<byte> s = new Span<byte>((byte*)p, sizeof(MatrixParallelTaskPackage));
s.Fill(0);
return p;
}
@@ -79,6 +95,7 @@ namespace StgSharp.Mathematics
{
_scalarAllocator = SlabAllocator<ScalarPacket>.Create(64, SlabBufferLayout.Chunked, true);
_wrapAllocator = SlabAllocator<MatrixParallelTaskPackage>.Create(64, SlabBufferLayout.Chunked, true);
_intermediateResult = new hlsfAllocator((nuint)(sizeof(MatrixKernel) * 64));
}
}