daily commit on 0917
This commit is contained in:
@@ -52,9 +52,27 @@ namespace StgSharp.Mathematics
|
||||
unsafe
|
||||
{
|
||||
MatrixParallelTaskPackage* handle = MatrixParallelFactory.CreateBaseTask();
|
||||
handle->Left = left.;
|
||||
handle->Right = right.Kernel;
|
||||
handle->Left = left.Buffer;
|
||||
handle->Right = right.Buffer;
|
||||
handle->Result = result.Buffer;
|
||||
handle->ComputeHandle = (IntPtr)InternalIO.Intrinsic.kernel_add;
|
||||
handle->LeftPrimOffset = 0;
|
||||
handle->RightPrimOffset = 0;
|
||||
handle->LeftPrimStride = left.KernelColumnLength;
|
||||
handle->LeftSecOffset = 1;
|
||||
handle->LeftPrimOffset = 0;
|
||||
handle->RightPrimOffset = 0;
|
||||
handle->RightPrimStride = right.KernelColumnLength;
|
||||
handle->RightSecOffset = 1;
|
||||
handle->RightPrimOffset = 0;
|
||||
handle->ResultPrimOffset = 0;
|
||||
handle->ResultPrimStride = result.KernelColumnLength;
|
||||
handle->ResultSecOffset = 1;
|
||||
handle->ResultPrimOffset = 0;
|
||||
handle->PrimCount = left.KernelRowLength;
|
||||
handle->SecCount = left.KernelColumnLength;
|
||||
}
|
||||
|
||||
MatrixParallel.LaunchParallel(SleepMode.DeepSleep);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using hlsfAllocator = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator;
|
||||
using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle;
|
||||
|
||||
// using hlsfHandle = global::StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocationHandle;
|
||||
|
||||
namespace StgSharp.Mathematics
|
||||
{
|
||||
@@ -67,17 +68,23 @@ namespace StgSharp.Mathematics
|
||||
set;
|
||||
} = null;
|
||||
|
||||
/// <summary>
|
||||
/// Length of the matrix in columns.
|
||||
/// </summary>
|
||||
public int ColumnLength { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Length of the matrix in rows.
|
||||
/// </summary>
|
||||
public int RowLength { get; init; }
|
||||
|
||||
public static MatrixAllocation DefaultAllocation { get; set; } = MatrixAllocation.GC;
|
||||
|
||||
internal abstract MatrixKernel* Buffer { get; }
|
||||
|
||||
protected int KernelColumnLength { get; init; }
|
||||
protected internal int KernelColumnLength { get; init; }
|
||||
|
||||
protected int KernelRowLength { get; init; }
|
||||
protected internal int KernelRowLength { get; init; }
|
||||
|
||||
public static Matrix<T> FromDefault(int columnLength, int rowLength)
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user