Switch matrix parallel to task stealing, type and wrap are refacored, thread execution core has not yet
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixParallel"
|
||||
// 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
|
||||
@@ -49,7 +49,7 @@ namespace StgSharp.Mathematics.Numeric
|
||||
#endif
|
||||
_lock = new();
|
||||
|
||||
private static ThreadPriority _AfterWork = ThreadPriority.Lowest;
|
||||
// private static ThreadPriority _AfterWork = ThreadPriority.Lowest;
|
||||
|
||||
public static bool SupportParallel { get; } = Environment.ProcessorCount > 6;
|
||||
|
||||
@@ -64,17 +64,6 @@ namespace StgSharp.Mathematics.Numeric
|
||||
Monitor.Exit(_lock);
|
||||
}
|
||||
|
||||
public static void LaunchParallel(MatrixParallelHandle handle, SleepMode afterWork)
|
||||
{
|
||||
_AfterWork = (ThreadPriority)afterWork;
|
||||
MatrixParallelThread leader = handle.GetLeader();
|
||||
foreach (MatrixParallelWrap w in handle.Wraps) {
|
||||
w.SetScheduler();
|
||||
}
|
||||
leader.MatrixParallelLeader();
|
||||
handle.WaitAllWraps();
|
||||
}
|
||||
|
||||
internal static void Init()
|
||||
{
|
||||
if (IsInitialized) {
|
||||
@@ -88,8 +77,10 @@ namespace StgSharp.Mathematics.Numeric
|
||||
}
|
||||
int count = Environment.ProcessorCount - 4;
|
||||
_threads = new(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
_threads.Push(new());
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
MatrixParallelThread thread = new MatrixParallelThread();
|
||||
_threads.Push(thread);
|
||||
}
|
||||
_awaitingLeaderHandle = new AwaitingQueue();
|
||||
IsInitialized = true;
|
||||
|
||||
Reference in New Issue
Block a user