L4 completely add support for multi predictor, working on ver 5 mat para

This commit is contained in:
Youmu Liu
2026-04-10 18:05:40 +08:00
parent b5bee5c442
commit 8a66c1697a
16 changed files with 602 additions and 191 deletions
@@ -0,0 +1,48 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallel.Numa"
// 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
{
public static unsafe partial class MatrixParallel
{
private static int[] NumaPayload;
private static MatrixParallelThread[,] NumaThreads;
private static void UpdateThreadPayload()
{
for (int i = 0; i < NumaPayload.Length; i++) { }
}
}
}
@@ -69,12 +69,8 @@ namespace StgSharp.Mathematics.Numeric
public ThreadPriority AfterWork { get; set; }
internal ref readonly IntrinsicContext Intrinsic => ref (*_context);
internal bool IsSingle { get; set; }
internal MatrixParallelWrap BindedWrap { get; set; }
internal MatrixThreadState State { get; private set; }
internal SIMDID Simd { get; private set; }
@@ -163,7 +159,6 @@ namespace StgSharp.Mathematics.Numeric
}
State = MatrixThreadState.Idle;
State = MatrixThreadState.Running;
AfterWork = BindedWrap.AfterWork;
_managedThread.Priority = ThreadPriority.Highest;
if (IsSingle)
{
@@ -173,17 +168,6 @@ namespace StgSharp.Mathematics.Numeric
IsSingle = false;
} else
{
PredictPolicy policy = BindedWrap.Policy;
switch (policy)
{
case PredictPolicy.Transparent:
break;
case PredictPolicy.BufferSequential:
break;
default:
break;
}
// MatrixParallelQueue taskQueue = BindedWrap.TaskQueue;
/*
if (0 > (int)p ->ComputeHandle) {
@@ -198,7 +182,6 @@ namespace StgSharp.Mathematics.Numeric
break;
}
/**/
BindedWrap.ReportThreadAccomplished();
}
_managedThread.Priority = AfterWork;
State = MatrixThreadState.Idle;
@@ -208,19 +191,19 @@ namespace StgSharp.Mathematics.Numeric
#pragma warning disable CA5393
[LibraryImport(Native.LibName, EntryPoint = "sn_get_simd_level_local")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
internal static partial ulong GetSimdId();
[LibraryImport(Native.LibName, EntryPoint = "sn_set_thread_affinity")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
internal static partial void SetThreadAffinity(
int coreId
);
[LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")]
[UnmanagedCallConv(CallConvs = [ typeof(CallConvCdecl) ])]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
private static unsafe partial void LoadIntrinsicFunction(
IntrinsicContext* context,