back to matrix, simplified thread init

This commit is contained in:
Youmu Liu
2026-03-24 13:45:14 +08:00
parent eee88e1098
commit d960d02972
3 changed files with 41 additions and 33 deletions
@@ -26,23 +26,13 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Collections;
using StgSharp.Internal;
using StgSharp.Mathematics.Internal;
using StgSharp.Mathematics.Internal;
using StgSharp.Mathematics.Memory;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
{
public static partial class MatrixParallel
public static unsafe partial class MatrixParallel
{
private static bool _meaningful;
@@ -51,7 +41,10 @@ namespace StgSharp.Mathematics.Numeric
public static bool IsParallelSupported { get; } = Environment.ProcessorCount > 6;
public static bool IsParallelMeaningful => (Environment.ProcessorCount > 6) && IsInitialized;
public static bool IsParallelMeaningful { get; } = (Environment.ProcessorCount > 6) &&
IsInitialized;
public static int ContextCount { get; private set; }
private static bool IsInitialized { get; set; }
@@ -75,7 +68,6 @@ namespace StgSharp.Mathematics.Numeric
MatrixParallelThread thread = new(i);
_threads.Push(thread);
SpinWait.SpinUntil(() => thread.State == MatrixThreadState.Ready);
var index = (IsParallelSupported && contextMap.TryGetValue(simd, out int index)) ? index : (-1);
}
// TODO 构建全局的保底上下文
@@ -96,18 +88,11 @@ namespace StgSharp.Mathematics.Numeric
}
[LibraryImport(Native.LibName, EntryPoint = "sn_compare_simd")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
private static unsafe partial ulong CompareSIMDID(
IntrinsicContext* context,
ulong id
);
[LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial void LoadIntrinsicFunction(
IntrinsicContext* context,
ulong id
);
}
}