back to matrix

This commit is contained in:
Youmu Liu
2026-03-23 20:11:08 +08:00
parent 0ac7b2b71f
commit eee88e1098
10 changed files with 100 additions and 179 deletions
@@ -69,10 +69,10 @@ namespace StgSharp.Mathematics.Numeric
internal ManualResetEventSlim? LeaderEvent { get; set; }
internal IntrinsicContext* Intrinsic { get; set; }
internal bool IsSingle { get; set; }
internal IntrinsicContext Intrinsic { get; private set; }
internal MatrixParallelWrap BindedWrap { get; set; }
internal MatrixThreadState State { get; set; }
@@ -91,16 +91,6 @@ namespace StgSharp.Mathematics.Numeric
_resetEvent.Set();
}
[LibraryImport(Native.LibName, EntryPoint = "sn_get_simd_level_local")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial ulong GetSimdId();
[LibraryImport(Native.LibName, EntryPoint = "sn_set_thread_affinity")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
internal static partial void SetThreadAffinity(
int coreId
);
protected virtual void Dispose(
bool disposing
)
@@ -125,11 +115,10 @@ namespace StgSharp.Mathematics.Numeric
// Bind OS-thread affinity once when the worker starts running
SetThreadAffinity(PoolId);
_ = Thread.Yield();
SIMDID feature = new()
{
Mask = GetSimdId()
};
_context = (nint*)MatrixParallel.GetContext(feature);
SIMDID feature = new(GetSimdId());
int index = MatrixParallel.GetContext(feature);
Intrinsic = new IntrinsicContext();
if (index > 0) { }
State = MatrixThreadState.Ready;
while (true)
{
@@ -171,5 +160,19 @@ namespace StgSharp.Mathematics.Numeric
State = MatrixThreadState.Retired;
}
#pragma warning disable CA5393
[LibraryImport(Native.LibName, EntryPoint = "sn_get_simd_level_local")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
internal static partial ulong GetSimdId();
[LibraryImport(Native.LibName, EntryPoint = "sn_set_thread_affinity")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
internal static partial void SetThreadAffinity(
int coreId
);
#pragma warning restore CA5393
}
}