From e3f2cf989daf23fa4f788f11d7a57f3a62afe06c Mon Sep 17 00:00:00 2001 From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com> Date: Wed, 18 Mar 2026 17:53:28 +0800 Subject: [PATCH] L4 briefly pass unit test --- .../IRegisterType.cs | 4 +- .../M128.cs | 2 +- .../M256.cs | 2 +- .../M512.cs | 2 +- .../M64.cs | 47 +++++++++++++------ StgSharp.Common/StgSharp.Common.csproj | 2 +- StgSharp.Mathematics/Internal/ScalarPacket.cs | 1 + .../Numeric/Runtime/MatrixParallelQueue.cs | 3 ++ .../Numeric/Runtime/MatrixParallelWrap.cs | 4 +- .../StgSharp.UnserInterface.csproj | 7 +++ StgSharp.UserInterface/VSS_Arch.md | 2 +- StgSharpDevelop.sln | 18 ++++++- 12 files changed, 69 insertions(+), 25 deletions(-) rename StgSharp.Common/HighPerformance/{RegisterAbstraction => ProcessorAbstraction}/IRegisterType.cs (98%) rename StgSharp.Common/HighPerformance/{RegisterAbstraction => ProcessorAbstraction}/M128.cs (98%) rename StgSharp.Common/HighPerformance/{RegisterAbstraction => ProcessorAbstraction}/M256.cs (97%) rename StgSharp.Common/HighPerformance/{RegisterAbstraction => ProcessorAbstraction}/M512.cs (97%) rename StgSharp.Common/HighPerformance/{RegisterAbstraction => ProcessorAbstraction}/M64.cs (70%) create mode 100644 StgSharp.UserInterface/StgSharp.UnserInterface.csproj 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/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/Runtime/MatrixParallelQueue.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs index d6526909..3e71981e 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; diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs index 354d0fa8..ef5c81a6 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs @@ -105,7 +105,7 @@ namespace StgSharp.Mathematics.Numeric public void WaitAllWraps() { if (_disposed) { - throw new ObjectDisposedException(typeof(MatrixParallelWrap).Name); + throw new ObjectDisposedException(nameof(MatrixParallelWrap)); } SpinWait.SpinUntil(() => Volatile.Read(ref _count) == 0); } @@ -114,7 +114,7 @@ namespace StgSharp.Mathematics.Numeric internal void ReportThreadAccomplished() { if (_disposed) { - throw new ObjectDisposedException(typeof(MatrixParallelWrap).Name); + throw new ObjectDisposedException(nameof(MatrixParallelWrap)); } Interlocked.Decrement(ref _count); } 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