diff --git a/.cr/team/Editor/Code Cleanup.xml b/.cr/team/Editor/Code Cleanup.xml
new file mode 100644
index 00000000..f4cdadea
--- /dev/null
+++ b/.cr/team/Editor/Code Cleanup.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+ -
+ False
+ False
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ True
+ True
+
+
+
+
+
+
+ -
+ True
+ True
+
+
+
+ -
+ True
+ True
+
+
+
+
+
\ No newline at end of file
diff --git a/StgSharp.Common/HighPerformance/RegisterAbstraction/IRegisterType.cs b/StgSharp.Common/HighPerformance/ProcessorAbstraction/IRegisterType.cs
similarity index 98%
rename from StgSharp.Common/HighPerformance/RegisterAbstraction/IRegisterType.cs
rename to StgSharp.Common/HighPerformance/ProcessorAbstraction/IRegisterType.cs
index eefa15c3..639dc2fa 100644
--- a/StgSharp.Common/HighPerformance/RegisterAbstraction/IRegisterType.cs
+++ b/StgSharp.Common/HighPerformance/ProcessorAbstraction/IRegisterType.cs
@@ -32,7 +32,7 @@ using System.Numerics;
using System.Text;
using System.Threading.Tasks;
-namespace StgSharp.Mathematics
+namespace StgSharp.HighPerformance.ProcessorAbstraction
{
///
/// Abstraction for a wide SIMD register or equivalent packed numeric storage. Provides raw
@@ -95,4 +95,4 @@ namespace StgSharp.Mathematics
ref T Member(int index) where T: unmanaged, INumber;
}
-}
\ No newline at end of file
+}
diff --git a/StgSharp.Common/HighPerformance/RegisterAbstraction/M128.cs b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M128.cs
similarity index 98%
rename from StgSharp.Common/HighPerformance/RegisterAbstraction/M128.cs
rename to StgSharp.Common/HighPerformance/ProcessorAbstraction/M128.cs
index a5330a4a..785d6fc9 100644
--- a/StgSharp.Common/HighPerformance/RegisterAbstraction/M128.cs
+++ b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M128.cs
@@ -36,7 +36,7 @@ using System.Runtime.Intrinsics.X86;
using System.Text;
-namespace StgSharp.Mathematics
+namespace StgSharp.HighPerformance.ProcessorAbstraction
{
[StructLayout(LayoutKind.Explicit, Pack = 16)]
public unsafe struct M128 : IRegisterPresentation
diff --git a/StgSharp.Common/HighPerformance/RegisterAbstraction/M256.cs b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M256.cs
similarity index 97%
rename from StgSharp.Common/HighPerformance/RegisterAbstraction/M256.cs
rename to StgSharp.Common/HighPerformance/ProcessorAbstraction/M256.cs
index 66bd328b..b605b604 100644
--- a/StgSharp.Common/HighPerformance/RegisterAbstraction/M256.cs
+++ b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M256.cs
@@ -35,7 +35,7 @@ using System.Runtime.Intrinsics;
using System.Text;
using System.Threading.Tasks;
-namespace StgSharp.Mathematics
+namespace StgSharp.HighPerformance.ProcessorAbstraction
{
[StructLayout(LayoutKind.Explicit, Pack = 16)]
public unsafe struct M256 : IRegisterPresentation
diff --git a/StgSharp.Common/HighPerformance/RegisterAbstraction/M512.cs b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M512.cs
similarity index 97%
rename from StgSharp.Common/HighPerformance/RegisterAbstraction/M512.cs
rename to StgSharp.Common/HighPerformance/ProcessorAbstraction/M512.cs
index 3f445442..b6fe2d61 100644
--- a/StgSharp.Common/HighPerformance/RegisterAbstraction/M512.cs
+++ b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M512.cs
@@ -35,7 +35,7 @@ using System.Runtime.Intrinsics;
using System.Text;
using System.Threading.Tasks;
-namespace StgSharp.Mathematics
+namespace StgSharp.HighPerformance.ProcessorAbstraction
{
[StructLayout(LayoutKind.Explicit, Size = 64, Pack = 64)]
public unsafe struct M512 : IRegisterPresentation
diff --git a/StgSharp.Common/HighPerformance/RegisterAbstraction/M64.cs b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M64.cs
similarity index 70%
rename from StgSharp.Common/HighPerformance/RegisterAbstraction/M64.cs
rename to StgSharp.Common/HighPerformance/ProcessorAbstraction/M64.cs
index e33db646..7fa3ceec 100644
--- a/StgSharp.Common/HighPerformance/RegisterAbstraction/M64.cs
+++ b/StgSharp.Common/HighPerformance/ProcessorAbstraction/M64.cs
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="M64"
// Project: StgSharp
-// AuthorGroup: Nitload Space
-// Copyright (c) Nitload Space. All rights reserved.
+// 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
@@ -30,7 +30,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
-namespace StgSharp.Mathematics
+namespace StgSharp.HighPerformance.ProcessorAbstraction
{
[StructLayout(LayoutKind.Explicit, Pack = 8)]
public unsafe struct M64 : IRegisterPresentation
@@ -47,17 +47,21 @@ namespace StgSharp.Mathematics
Unsafe.SkipInit(out value);
}
- public ref T AsRef() where T: unmanaged,INumber
+ public ref T AsRef() where T : unmanaged,INumber
{
return ref Unsafe.As(ref buffer[0]);
}
- public void BroadCastFrom(T value) where T: unmanaged, INumber
+ public void BroadCastFrom(
+ T value
+ ) where T : unmanaged, INumber
{
vec = Vector64.Create(value).AsSingle();
}
- public override bool Equals(object obj)
+ public override bool Equals(
+ object obj
+ )
{
return obj is M64 m64 && this == m64;
}
@@ -68,32 +72,47 @@ namespace StgSharp.Mathematics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ref T Member(int index) where T: unmanaged, INumber
+ public ref T Member(
+ int index
+ ) where T : unmanaged, INumber
{
return ref Unsafe.As(ref buffer[index * sizeof(T)]);
}
- public static bool operator !=(M64 left, M64 right)
+ public static bool operator !=(
+ M64 left,
+ M64 right
+ )
{
return !(left == right);
}
- public static M64 operator <<(M64 value, int shift)
+ public static M64 operator <<(
+ M64 value,
+ int shift
+ )
{
M64 result = new M64();
result.value = value.value << shift;
return result;
}
- public static bool operator ==(M64 left, M64 right)
+ public static bool operator ==(
+ M64 left,
+ M64 right
+ )
{
return left.value == right.value;
}
- public static M64 operator >>(M64 value, int shift)
+ public static M64 operator >>(
+ M64 value,
+ int shift
+ )
{
- M64 result = new M64();
- result.value = value.value << shift;
- return result;
+ return new()
+ {
+ value = value.value << shift
+ };
}
}
diff --git a/StgSharp.Common/StgSharp.Common.csproj b/StgSharp.Common/StgSharp.Common.csproj
index fe8d2d8d..2fea7354 100644
--- a/StgSharp.Common/StgSharp.Common.csproj
+++ b/StgSharp.Common/StgSharp.Common.csproj
@@ -24,7 +24,7 @@
-
+
\ No newline at end of file
diff --git a/StgSharp.Mathematics/Internal/IntrinsicContext.cs b/StgSharp.Mathematics/Internal/IntrinsicContext.cs
index c49c68a4..3da2ede2 100644
--- a/StgSharp.Mathematics/Internal/IntrinsicContext.cs
+++ b/StgSharp.Mathematics/Internal/IntrinsicContext.cs
@@ -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)]
@@ -171,4 +179,4 @@ namespace StgSharp.Mathematics.Internal
#endregion
-}
\ No newline at end of file
+}
diff --git a/StgSharp.Mathematics/Internal/MatrixParallelTask.cs b/StgSharp.Mathematics/Internal/MatrixParallelTask.cs
index 32e2a01a..abe9bcdd 100644
--- a/StgSharp.Mathematics/Internal/MatrixParallelTask.cs
+++ b/StgSharp.Mathematics/Internal/MatrixParallelTask.cs
@@ -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;
@@ -65,4 +65,4 @@ namespace StgSharp.Mathematics.Internal
}
}
-}
\ No newline at end of file
+}
diff --git a/StgSharp.Mathematics/Internal/ScalarPacket.cs b/StgSharp.Mathematics/Internal/ScalarPacket.cs
index f9092365..fee451bf 100644
--- a/StgSharp.Mathematics/Internal/ScalarPacket.cs
+++ b/StgSharp.Mathematics/Internal/ScalarPacket.cs
@@ -25,6 +25,7 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
+using StgSharp.HighPerformance.ProcessorAbstraction;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/StgSharp.Mathematics/Numeric/Linear/MatrixCompute.Sequential.cs b/StgSharp.Mathematics/Numeric/Linear/MatrixCompute.Sequential.cs
new file mode 100644
index 00000000..614b61cf
--- /dev/null
+++ b/StgSharp.Mathematics/Numeric/Linear/MatrixCompute.Sequential.cs
@@ -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];
+
+namespace StgSharp.Mathematics.Numeric.Linear
+{
+ public static unsafe partial class MatrixCompute
+ {
+
+ public static void Add(
+ Matrix left,
+ Matrix right,
+ Matrix 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(
+ left, right, ans
+ );
+ }
+ MatrixElementType f32 = MatrixElementType.F32;
+ long count = ((long)left.KernelColumnLength) * left.KernelRowLength;
+
+ MatrixKernel* leftPtr = left.Buffer;
+ MatrixKernel* rightPtr = right.Buffer;
+ MatrixKernel* 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(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((nuint)add, t);
+
+ taskGroup.LaunchParallel(SleepMode.DeepSleep);
+ taskGroup.Dispose();
+ return;
+ }
+
+ private sealed class SequentialPredictor : MatrixPredictor
+ {
+
+ public override bool Predict(
+ Span node,
+ out int count
+ )
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void Prefetch(
+ nuint origin,
+ ulong policy,
+ Span cache
+ )
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void WriteBack(
+ nuint origin,
+ ulong policy,
+ ReadOnlySpan cache
+ )
+ {
+ throw new NotImplementedException();
+ }
+
+ }
+
+ }
+}
diff --git a/StgSharp.Mathematics/Numeric/Linear/MatrixCompute.cs b/StgSharp.Mathematics/Numeric/Linear/MatrixCompute.cs
index ae6cbc33..371c325c 100644
--- a/StgSharp.Mathematics/Numeric/Linear/MatrixCompute.cs
+++ b/StgSharp.Mathematics/Numeric/Linear/MatrixCompute.cs
@@ -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* buffer,
int colLength,
int x,
- int y)
- where T: unmanaged, INumber
+ int y
+ ) where T : unmanaged, INumber
{
return (MatrixKernel*)(buffer + (colLength * x + y));
}
diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs
index 09462fdc..44937827 100644
--- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs
+++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs
@@ -26,10 +26,12 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Collections;
+using StgSharp.HighPerformance.Memory;
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;
@@ -46,16 +48,10 @@ namespace StgSharp.Mathematics.Numeric
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal static unsafe MatrixParallelWrap ScheduleTask(
+ internal static unsafe MatrixParallelWrap ScheduleTask(
+ nuint computeHandle,
MatrixParallelTask* package
- )
- {
- return ScheduleBufferTask(package);
- }
-
- private static unsafe MatrixParallelWrap ScheduleBufferTask(
- MatrixParallelTask* package
- )
+ ) where TTask : IPrefetchPredict
{
/*
int primCount = package->PrimCount;
@@ -67,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;
}
diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs
index d6526909..c2838d83 100644
--- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs
+++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using Microsoft.VisualBasic.FileIO;
+using StgSharp.HighPerformance.Memory;
using StgSharp.Mathematics.Internal;
using System;
using System.Collections.Concurrent;
@@ -41,6 +42,8 @@ namespace StgSharp.Mathematics.Numeric
internal unsafe class MatrixParallelQueue
{
+ // TODO 为各种不同的计算策略设计专门的预测器,以适配L4
+
private static ConcurrentStack _recycle = [];
private MatrixParallelTask* _package;
private ulong _cursor;
@@ -58,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;
}
diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs
index 354d0fa8..c6f8f51a 100644
--- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs
+++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs
@@ -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 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(typeof(MatrixParallelWrap).Name);
- }
- SpinWait.SpinUntil(() => Volatile.Read(ref _count) == 0);
+ ObjectDisposedException.ThrowIf(_disposed, nameof(MatrixParallelWrap));
+ _countdownEvent.Wait();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal void ReportThreadAccomplished()
+ {
+ ObjectDisposedException.ThrowIf(_disposed, nameof(MatrixParallelWrap));
+ _ = _countdownEvent.Signal();
+ }
+
+ private void Dispose(
+ bool disposing
+ )
{
if (_disposed) {
- throw new ObjectDisposedException(typeof(MatrixParallelWrap).Name);
+ return;
}
- Interlocked.Decrement(ref _count);
+ if (disposing)
+ {
+ MatrixParallel.ReturnParallelResources(ref _threads);
+ _countdownEvent.Dispose();
+ }
+ _disposed = true;
}
}
diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixPredictor.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixPredictor.cs
new file mode 100644
index 00000000..743de23b
--- /dev/null
+++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixPredictor.cs
@@ -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 : IPrefetchPredict
+ where TSelf : MatrixPredictor
+ {
+
+ public abstract bool Predict(
+ Span node,
+ out int count
+ );
+
+ public abstract void Prefetch(
+ nuint origin,
+ ulong policy,
+ Span cache
+ );
+
+ public abstract void WriteBack(
+ nuint origin,
+ ulong policy,
+ ReadOnlySpan cache
+ );
+
+ }
+}
diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixTaskFactory.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixTaskFactory.cs
deleted file mode 100644
index 6b0c5fce..00000000
--- a/StgSharp.Mathematics/Numeric/Runtime/MatrixTaskFactory.cs
+++ /dev/null
@@ -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 _scalarAllocator ;
-
- private static SlabAllocator _wrapAllocator;
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static MatrixParallelTask* CreateBaseTask()
- {
- MatrixParallelTask* p = (MatrixParallelTask*)_wrapAllocator.Allocate();
- Span s = new Span((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(64 * 1024, SlabBufferLayout.Chunked);
- _wrapAllocator = SlabAllocator.
- Create(128 * 1024, SlabBufferLayout.Chunked);
- }
- }
-
- }
-}
diff --git a/StgSharp.UserInterface/StgSharp.UnserInterface.csproj b/StgSharp.UserInterface/StgSharp.UnserInterface.csproj
new file mode 100644
index 00000000..1ac5b9cc
--- /dev/null
+++ b/StgSharp.UserInterface/StgSharp.UnserInterface.csproj
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StgSharp.UserInterface/VSS_Arch.md b/StgSharp.UserInterface/VSS_Arch.md
index 7ab0a09e..f05583a8 100644
--- a/StgSharp.UserInterface/VSS_Arch.md
+++ b/StgSharp.UserInterface/VSS_Arch.md
@@ -472,4 +472,4 @@ window.Show();
---
-*本文档随项目演进持续更新。架构思想的提出与设计版权归 Nitload-NSI 所有。*
\ No newline at end of file
+*本文档随项目演进持续更新。架构思想的提出与设计版权归 Nitload 所有。*
diff --git a/StgSharpDevelop.sln b/StgSharpDevelop.sln
index 941862be..51c8ccbd 100644
--- a/StgSharpDevelop.sln
+++ b/StgSharpDevelop.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 18
-VisualStudioVersion = 18.3.11520.95 d18.3
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36705.20 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.Common", "StgSharp.Common\StgSharp.Common.csproj", "{3EAF2EE6-FA9E-4F57-951F-7E6F8125DFBF}"
ProjectSection(ProjectDependencies) = postProject
@@ -34,6 +34,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.RegularAnalysis",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StgSharp.Graphics", "StgSharp.Graphics\StgSharp.Graphics.csproj", "{80CD3DDE-0642-451D-82DF-0DE422FC6E34}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.UnserInterface", "StgSharp.UserInterface\StgSharp.UnserInterface.csproj", "{E999C63D-93F8-DE1C-C004-6D7E8172FE68}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM64 = Debug|ARM64
@@ -152,6 +154,18 @@ Global
{80CD3DDE-0642-451D-82DF-0DE422FC6E34}.Release|ARM64.Build.0 = Release|ARM64
{80CD3DDE-0642-451D-82DF-0DE422FC6E34}.Release|x64.ActiveCfg = Release|x64
{80CD3DDE-0642-451D-82DF-0DE422FC6E34}.Release|x64.Build.0 = Release|x64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Debug|ARM64.Build.0 = Debug|ARM64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Debug|x64.ActiveCfg = Debug|x64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Debug|x64.Build.0 = Debug|x64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.PerformanceDebug|ARM64.ActiveCfg = PerformanceDebug|ARM64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.PerformanceDebug|ARM64.Build.0 = PerformanceDebug|ARM64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.PerformanceDebug|x64.ActiveCfg = PerformanceDebug|x64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.PerformanceDebug|x64.Build.0 = PerformanceDebug|x64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Release|ARM64.ActiveCfg = Release|ARM64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Release|ARM64.Build.0 = Release|ARM64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Release|x64.ActiveCfg = Release|x64
+ {E999C63D-93F8-DE1C-C004-6D7E8172FE68}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE