back to matrix, but trouble in combining L4 predict with matrixparallelqueue
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Root Type="DevExpress.CodeAnalysis.CodeCleanUp.CodeCleanUpOptions">
|
||||
<Options Language="C#">
|
||||
<Providers>
|
||||
<Item Id="{ef51c8cb-e48a-498f-98b2-eadda592c4c7}" />
|
||||
<Item Id="{C47B114F-EEAE-46FC-9562-454E8F9196C0}" />
|
||||
<Item Id="{20943A7B-2B32-4727-8E9D-61CB5B5F2A0D}" />
|
||||
<Item Id="{528bdd86-5882-4b4c-b717-e0ec33958bd7}" />
|
||||
<Item Id="{40c971cf-ebeb-419d-a559-6183d8d0d6a4}" />
|
||||
<Item Id="{00bb41b3-3de9-458a-93c1-1f126253eab0}" />
|
||||
<Item Id="{4B42E272-EE39-4E83-924C-B2458D827DE3}" />
|
||||
<Item Id="{0e6b7b2c-84e6-4eee-83d1-6149282c8501}">
|
||||
<Enabled>False</Enabled>
|
||||
<ApplyOnSave>False</ApplyOnSave>
|
||||
</Item>
|
||||
<Item Id="{8e24f031-d25c-4ddb-86a5-c28f8fc354eb}" />
|
||||
<Item Id="{03781427-dea7-45b0-9eef-81abe2961a61}" />
|
||||
<Item Id="{37bde68f-a39d-4791-adba-8ad7b2952ab0}" />
|
||||
<Item Id="{d2f76d4e-97a9-4031-a7a2-23f192201426}" />
|
||||
<Item Id="{bb96a982-bed0-4d8f-93a7-1e1ce7493e96}" />
|
||||
<Item Id="{3824f6f0-fee1-4847-94ff-1efa133ba199}" />
|
||||
<Item Id="{e950f01e-2b15-4da5-8176-cafe3cc883d9}" />
|
||||
<Item Id="{12f6d456-d2ec-407e-aa44-2b74d7c56e9c}" />
|
||||
<Item Id="{d24bd9c7-7686-4101-9ec1-f61c19af8d2e}" />
|
||||
<Item Id="{f804e36e-414f-409c-9b90-63b7727745a7}" />
|
||||
<Item Id="{ffa114f4-9122-46e4-96c8-655d54c904e6}" />
|
||||
<Item Id="{5d712912-91ed-4728-ba16-ac1821b702ca}" />
|
||||
<Item Id="{4216ef39-52bd-4e7f-92a7-673406f92bc8}" />
|
||||
<Item Id="{f410df1e-6e44-4854-a3f0-14bb756113f9}" />
|
||||
<Item Id="{ab07124b-0893-4a2d-b6f5-39bfa9f10148}" />
|
||||
<Item Id="{163af547-186c-4fa1-9a3e-b9b0a1ceec32}" />
|
||||
<Item Id="{73a73e0e-5575-4c34-a97b-a942c6da1f90}" />
|
||||
<Item Id="{f7752b2b-7ba5-43ec-b0f7-7f45c21c1c23}" />
|
||||
<Item Id="{9dab2827-57cc-40e9-a330-a0626261453e}" />
|
||||
<Item Id="{6bf7cfc1-1332-4bec-982e-c2d0968237cd}">
|
||||
<Enabled>True</Enabled>
|
||||
<ApplyOnSave>True</ApplyOnSave>
|
||||
</Item>
|
||||
<Item Id="{7e640eab-b585-47a5-afdc-0f110357cebb}" />
|
||||
<Item Id="{44ac74a7-dba7-45aa-b2ca-8094b85cb9c9}" />
|
||||
<Item Id="{2cd1441b-9e0f-4e39-bd8c-8aaa6e2a1728}" />
|
||||
<Item Id="{41388575-074b-49f2-b3bc-9d28b212bd1a}" />
|
||||
<Item Id="{4fa0bfa3-0a7e-471b-9933-3a379bdd5bd7}" />
|
||||
<Item Id="{1f88209e-45e2-40b9-a235-1df251df05dd}">
|
||||
<Enabled>True</Enabled>
|
||||
<ApplyOnSave>True</ApplyOnSave>
|
||||
</Item>
|
||||
<Item Id="{086b0e70-893d-4b97-a6cf-d366ddbae573}" />
|
||||
<Item Id="{4771fd98-4357-4780-b479-a7a875fec011}" />
|
||||
<Item Id="{174C98E6-48C4-42D0-BC30-35EDE6377C9B}">
|
||||
<Enabled>True</Enabled>
|
||||
<ApplyOnSave>True</ApplyOnSave>
|
||||
</Item>
|
||||
<Item Id="{53ccb10f-f7af-40a6-9472-d05054672052}" />
|
||||
</Providers>
|
||||
</Options>
|
||||
</Root>
|
||||
@@ -159,6 +159,14 @@ namespace StgSharp.Mathematics.Internal
|
||||
scalar);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public readonly nint Get(
|
||||
MatrixIntrinsicHandle index
|
||||
)
|
||||
{
|
||||
return this[(int)index];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[InlineArray(MatrixElementType.IntrinsicCount)]
|
||||
|
||||
@@ -36,10 +36,10 @@ namespace StgSharp.Mathematics.Internal
|
||||
internal unsafe struct MatrixParallelTask
|
||||
{
|
||||
|
||||
[FieldOffset(0)]public MatrixKernel* Mat1; // 8
|
||||
[FieldOffset(0)] public MatrixKernel* Mat1; // 8
|
||||
[FieldOffset(8)] public MatrixKernel* Mat2; // 8
|
||||
[FieldOffset(16)] public MatrixKernel* Mat3; // 16
|
||||
[FieldOffset(40)] public int Common_k;
|
||||
[FieldOffset(40)] public int CommonK;
|
||||
[FieldOffset(32)] public int CommonX;
|
||||
[FieldOffset(36)] public int CommonY;
|
||||
[FieldOffset(44)] public int i;
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixCompute.Sequential"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance.Memory;
|
||||
using StgSharp.Mathematics.Numeric.Runtime;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using unsafe MkProc = delegate* unmanaged[Cdecl]<StgSharp.Mathematics.Internal.MatrixParallelTask*, void>;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric.Linear
|
||||
{
|
||||
public static unsafe partial class MatrixCompute
|
||||
{
|
||||
|
||||
public static void Add(
|
||||
Matrix<float> left,
|
||||
Matrix<float> right,
|
||||
Matrix<float> ans
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(left, nameof(left));
|
||||
ArgumentNullException.ThrowIfNull(right, nameof(right));
|
||||
ArgumentNullException.ThrowIfNull(ans, nameof(ans));
|
||||
if ((left.ColumnLength != right.ColumnLength) ||
|
||||
(left.RowLength != right.RowLength) ||
|
||||
(left.ColumnLength != ans.ColumnLength) ||
|
||||
(left.RowLength != ans.RowLength)) {
|
||||
throw new MatrixDimensionMismatchException<float>(
|
||||
left, right, ans
|
||||
);
|
||||
}
|
||||
MatrixElementType f32 = MatrixElementType.F32;
|
||||
long count = ((long)left.KernelColumnLength) * left.KernelRowLength;
|
||||
|
||||
MatrixKernel<float>* leftPtr = left.Buffer;
|
||||
MatrixKernel<float>* rightPtr = right.Buffer;
|
||||
MatrixKernel<float>* ansPtr = ans.Buffer;
|
||||
MkProc add = (MkProc)NumericalModule.GlobalContext.
|
||||
mat_mk[f32.IntrinsicNode].
|
||||
Get(MatrixIntrinsicHandle.Add);
|
||||
MatrixParallelTask* t = stackalloc MatrixParallelTask[1];
|
||||
|
||||
t->Mat1 = (MatrixKernel*)leftPtr;
|
||||
t->Mat2 = (MatrixKernel*)rightPtr;
|
||||
t->Mat3 = (MatrixKernel*)ansPtr;
|
||||
t->ElementType = MatrixElementType.F64;
|
||||
t->Scalar.Data<long>(0) = count;
|
||||
if (count <= 256)
|
||||
{
|
||||
add(t);
|
||||
|
||||
// .buffer_add(leftPtr, rightPtr, ansPtr, count);
|
||||
|
||||
return;
|
||||
} else if (count <= 1024)
|
||||
{
|
||||
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
|
||||
add(t);
|
||||
MatrixParallel.ReturnParallelResources(ref pool);
|
||||
return;
|
||||
}
|
||||
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask<SequentialPredictor>((nuint)add, t);
|
||||
|
||||
taskGroup.LaunchParallel(SleepMode.DeepSleep);
|
||||
taskGroup.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
private sealed class SequentialPredictor : MatrixPredictor<SequentialPredictor>
|
||||
{
|
||||
|
||||
public override bool Predict(
|
||||
Span<CacheLinePrediction> node,
|
||||
out int count
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void Prefetch(
|
||||
nuint origin,
|
||||
ulong policy,
|
||||
Span<byte> cache
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void WriteBack(
|
||||
nuint origin,
|
||||
ulong policy,
|
||||
ReadOnlySpan<byte> cache
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance.Memory;
|
||||
using StgSharp.Internal;
|
||||
using StgSharp.Mathematics;
|
||||
using System;
|
||||
@@ -37,7 +38,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
public partial class MatrixCompute
|
||||
public static partial class MatrixCompute
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -45,8 +46,8 @@ namespace StgSharp.Mathematics.Numeric
|
||||
MatrixKernel<T>* buffer,
|
||||
int colLength,
|
||||
int x,
|
||||
int y)
|
||||
where T: unmanaged, INumber<T>
|
||||
int y
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
return (MatrixKernel*)(buffer + (colLength * x + y));
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -48,6 +49,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
internal static unsafe MatrixParallelWrap ScheduleTask<TTask>(
|
||||
nuint computeHandle,
|
||||
MatrixParallelTask* package
|
||||
) where TTask : IPrefetchPredict
|
||||
{
|
||||
@@ -61,8 +63,10 @@ namespace StgSharp.Mathematics.Numeric
|
||||
|
||||
long recommendCount = /*count / /**/ 1024;
|
||||
MatrixParallelThread[] pool = LeadParallel((int)recommendCount);
|
||||
MatrixParallelWrap wrap = new MatrixParallelWrap(pool);
|
||||
wrap.TaskQueue = MatrixParallelQueue.Rent(package);
|
||||
MatrixParallelWrap wrap = new(pool)
|
||||
{
|
||||
TaskQueue = MatrixParallelQueue.Rent(package)
|
||||
};
|
||||
return wrap;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
queue = new MatrixParallelQueue();
|
||||
}
|
||||
queue._package = pack;
|
||||
queue._maxCount = (ulong)pack->CommonX * (ulong)pack->CommonY;
|
||||
queue._maxCount = ((ulong)pack->CommonX) * ((ulong)pack->CommonY);
|
||||
queue._cursor = 0;
|
||||
return queue;
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ namespace StgSharp.Mathematics.Numeric
|
||||
|
||||
}
|
||||
|
||||
public class MatrixParallelWrap : IDisposable
|
||||
public sealed class MatrixParallelWrap : IDisposable
|
||||
{
|
||||
|
||||
private MatrixParallelThread[] _threads;
|
||||
private bool _disposed = false;
|
||||
private int _count;
|
||||
private bool _disposed;
|
||||
private readonly CountdownEvent _countdownEvent;
|
||||
|
||||
internal MatrixParallelWrap(
|
||||
MatrixParallelThread[] threadArray
|
||||
@@ -60,7 +60,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
_threads = threadArray;
|
||||
IsMultithread = threadArray.Length > 1;
|
||||
_count = threadArray.Length;
|
||||
_countdownEvent = new CountdownEvent(threadArray.Length);
|
||||
}
|
||||
|
||||
public ReadOnlySpan<MatrixParallelThread> Threads
|
||||
@@ -81,11 +81,8 @@ namespace StgSharp.Mathematics.Numeric
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed) {
|
||||
return;
|
||||
}
|
||||
MatrixParallel.ReturnParallelResources(ref _threads);
|
||||
_disposed = true;
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -104,19 +101,30 @@ namespace StgSharp.Mathematics.Numeric
|
||||
|
||||
public void WaitAllWraps()
|
||||
{
|
||||
if (_disposed) {
|
||||
throw new ObjectDisposedException(nameof(MatrixParallelWrap));
|
||||
}
|
||||
SpinWait.SpinUntil(() => Volatile.Read(ref _count) == 0);
|
||||
ObjectDisposedException.ThrowIf(_disposed, nameof(MatrixParallelWrap));
|
||||
_countdownEvent.Wait();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void ReportThreadAccomplished()
|
||||
{
|
||||
if (_disposed) {
|
||||
throw new ObjectDisposedException(nameof(MatrixParallelWrap));
|
||||
ObjectDisposedException.ThrowIf(_disposed, nameof(MatrixParallelWrap));
|
||||
_ = _countdownEvent.Signal();
|
||||
}
|
||||
Interlocked.Decrement(ref _count);
|
||||
|
||||
private void Dispose(
|
||||
bool disposing
|
||||
)
|
||||
{
|
||||
if (_disposed) {
|
||||
return;
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
MatrixParallel.ReturnParallelResources(ref _threads);
|
||||
_countdownEvent.Dispose();
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixPredictor"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.HighPerformance.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric.Runtime
|
||||
{
|
||||
public abstract class MatrixPredictor<TSelf> : IPrefetchPredict
|
||||
where TSelf : MatrixPredictor<TSelf>
|
||||
{
|
||||
|
||||
public abstract bool Predict(
|
||||
Span<CacheLinePrediction> node,
|
||||
out int count
|
||||
);
|
||||
|
||||
public abstract void Prefetch(
|
||||
nuint origin,
|
||||
ulong policy,
|
||||
Span<byte> cache
|
||||
);
|
||||
|
||||
public abstract void WriteBack(
|
||||
nuint origin,
|
||||
ulong policy,
|
||||
ReadOnlySpan<byte> cache
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixTaskFactory"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Internal;
|
||||
using StgSharp.Mathematics.Memory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using hlsfAllocator = StgSharp.Mathematics.Memory.HybridLayerSegregatedFitAllocator;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
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<MatrixParallelTask> _wrapAllocator;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static MatrixParallelTask* CreateBaseTask()
|
||||
{
|
||||
MatrixParallelTask* p = (MatrixParallelTask*)_wrapAllocator.Allocate();
|
||||
Span<byte> s = new Span<byte>((byte*)p, sizeof(MatrixParallelTask));
|
||||
s.Fill(0);
|
||||
return p;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ScalarPacket* CreateScalarPacket()
|
||||
{
|
||||
ScalarPacket* p = (ScalarPacket*)_scalarAllocator.Allocate();
|
||||
return p;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static unsafe MatrixParallelTask* FromExistPackage(
|
||||
MatrixParallelTask* exist
|
||||
)
|
||||
{
|
||||
MatrixParallelTask* ptr = (MatrixParallelTask*)_wrapAllocator.Allocate();
|
||||
MatrixParallelTask.Copy(exist, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
public static void Release(
|
||||
ScalarPacket* source
|
||||
)
|
||||
{
|
||||
_scalarAllocator.Free((nuint)source);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Release(
|
||||
MatrixParallelTask* source
|
||||
)
|
||||
{
|
||||
_wrapAllocator.Free((nuint)source);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static void Init()
|
||||
{
|
||||
if (_intermediateResult is null)
|
||||
{
|
||||
_intermediateResult = new hlsfAllocator(64 * 16 * 16);
|
||||
_scalarAllocator = SlabAllocator.Create<ScalarPacket>(64 * 1024, SlabBufferLayout.Chunked);
|
||||
_wrapAllocator = SlabAllocator.
|
||||
Create<MatrixParallelTask>(128 * 1024, SlabBufferLayout.Chunked);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user