finally find pos to inject prediction to predictor
This commit is contained in:
@@ -42,7 +42,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
{
|
||||
internal unsafe ref struct MatrixParallelQueue
|
||||
internal unsafe ref struct MatrixParallelQueue<TPredictor> where TPredictor: unmanaged, IMatrixPredictor<TPredictor>
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixParallelThread"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. 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
|
||||
@@ -51,13 +51,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
|
||||
private IntrinsicContext* _context;
|
||||
private MatrixParallelTask* _currentTask;
|
||||
private volatile bool _disposed, _isRetireRequested, _isReinitRequested;
|
||||
private volatile bool _disposed, _isRetireRequested;
|
||||
private readonly ManualResetEventSlim _resetEvent;
|
||||
private Thread _managedThread;
|
||||
|
||||
internal MatrixParallelThread(
|
||||
int poolId
|
||||
)
|
||||
internal MatrixParallelThread(int poolId)
|
||||
{
|
||||
_resetEvent = new ManualResetEventSlim(false);
|
||||
_managedThread = new Thread(MatrixParallelWorkLoad);
|
||||
@@ -91,23 +89,6 @@ namespace StgSharp.Mathematics.Numeric
|
||||
_resetEvent.Set();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void ReInit()
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, nameof(MatrixParallelThread));
|
||||
if (State != MatrixThreadState.Retired) {
|
||||
return;
|
||||
}
|
||||
BindedWrap = null!;
|
||||
_currentTask = null;
|
||||
IsSingle = false;
|
||||
_isRetireRequested = false;
|
||||
_isReinitRequested = true;
|
||||
_resetEvent.Set();
|
||||
_managedThread = new Thread(MatrixParallelWorkLoad);
|
||||
SpinWait.SpinUntil(() => State != MatrixThreadState.Retired);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void Retire()
|
||||
{
|
||||
@@ -122,18 +103,14 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void SetSingleThreadTask(
|
||||
ref MatrixParallelTask task
|
||||
)
|
||||
internal void SetSingleThreadTask(ref MatrixParallelTask task)
|
||||
{
|
||||
if (IsSingle) {
|
||||
*_currentTask = task;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Dispose(
|
||||
bool disposing
|
||||
)
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
@@ -178,12 +155,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
State = MatrixThreadState.Retired;
|
||||
continue;
|
||||
}
|
||||
if (_isReinitRequested)
|
||||
{
|
||||
_isReinitRequested = false;
|
||||
State = MatrixThreadState.Idle;
|
||||
continue;
|
||||
}
|
||||
State = MatrixThreadState.Idle;
|
||||
State = MatrixThreadState.Running;
|
||||
AfterWork = BindedWrap.AfterWork;
|
||||
_managedThread.Priority = ThreadPriority.Highest;
|
||||
@@ -195,6 +167,17 @@ namespace StgSharp.Mathematics.Numeric
|
||||
IsSingle = false;
|
||||
} else
|
||||
{
|
||||
PredictPolicy policy = BindedWrap.Policy;
|
||||
switch (policy)
|
||||
{
|
||||
case PredictPolicy.Transparent:
|
||||
break;
|
||||
case PredictPolicy.Sequential:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// MatrixParallelQueue taskQueue = BindedWrap.TaskQueue;
|
||||
/*
|
||||
if (0 > (int)p ->ComputeHandle) {
|
||||
@@ -226,17 +209,12 @@ namespace StgSharp.Mathematics.Numeric
|
||||
[LibraryImport(Native.LibName, EntryPoint = "sn_set_thread_affinity")]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
|
||||
internal static partial void SetThreadAffinity(
|
||||
int coreId
|
||||
);
|
||||
internal static partial void SetThreadAffinity(int coreId);
|
||||
|
||||
[LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
||||
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
|
||||
private static unsafe partial void LoadIntrinsicFunction(
|
||||
IntrinsicContext* context,
|
||||
ulong id
|
||||
);
|
||||
private static unsafe partial void LoadIntrinsicFunction(IntrinsicContext* context, ulong id);
|
||||
#pragma warning restore CA5393
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user