diff --git a/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs b/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs index f28bbada..08ef61dc 100644 --- a/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs +++ b/StgSharp.Mathematics/Numeric/MatrixCompute.Basic.cs @@ -65,6 +65,8 @@ namespace StgSharp.Mathematics.Numeric } Stack taskGroup = MatrixParallel.PublicTask(left.GetColumnEnumeration(), right.GetColumnEnumeration(), ans.GetColumnEnumeration(), (delegate**, MatrixKernel*, MatrixKernel*, void>)NativeIntrinsic.Intrinsic.f32_add); + + MatrixParallel.LaunchParallel(taskGroup, SleepMode.DeepSleep); /* * run parallel */ diff --git a/StgSharp.Mathematics/Numeric/MatrixParallel.cs b/StgSharp.Mathematics/Numeric/MatrixParallel.cs index 76d3834b..e111b859 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallel.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallel.cs @@ -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 @@ -55,7 +55,8 @@ namespace StgSharp.Mathematics.Numeric { private static Thread[] _threads; - private static readonly (int a, int b)[] LookupTable = [ (1, 1), // 7 + private static readonly (int a, int b)[] LookupTable = [ + (1, 1), // 7 (0, 2), // 8 (no non-zero solution) (3, 0), // 9 (no non-zero solution) (2, 1), // 10 @@ -133,7 +134,10 @@ namespace StgSharp.Mathematics.Numeric } } else if (count == 6) { - Pool = new(6, [ new MatrixParallelWrap(0, 3), new MatrixParallelWrap(3, 3) ]); + Pool = new(6, [ + new MatrixParallelWrap(0, 3), + new MatrixParallelWrap(3, 3) + ]); (LargeWrapCount, SmallWrapCount) = (0, 2); } else { @@ -155,7 +159,10 @@ namespace StgSharp.Mathematics.Numeric { RemainThreadCount = _threads.Length; _AfterWork = (ThreadPriority)afterWork; - SetAllWrap(wraps); + ResetThreadCount(); + foreach (MatrixParallelWrap w in wraps) { + w.SchedulerReset.Set(); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -171,14 +178,6 @@ namespace StgSharp.Mathematics.Numeric RemainThreadCount = _threads.Length; } - public static void SetAllWrap(IEnumerable wraps) - { - ResetThreadCount(); - foreach (MatrixParallelWrap item in wraps) { - item.SchedulerReset.Set(); - } - } - #region wrap field private static MatrixParallelPool Pool; diff --git a/StgSharp.Mathematics/Numeric/MatrixParallelWrap.cs b/StgSharp.Mathematics/Numeric/MatrixParallelWrap.cs index eef520c1..54101f95 100644 --- a/StgSharp.Mathematics/Numeric/MatrixParallelWrap.cs +++ b/StgSharp.Mathematics/Numeric/MatrixParallelWrap.cs @@ -25,6 +25,7 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using StgSharp.HighPerformance; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -216,4 +217,18 @@ namespace StgSharp.Mathematics.Numeric DeepSleep = ThreadPriority.Lowest, } + + public class MatrixComputeResource + { + + public IEnumerable Wraps { get; set; } + + public int WorkingThreadCount { get; set; } + + /// + /// Closure task leader should do to collect results. + /// + public unsafe IntPtr LeaderClosurePackage { get; set; } + + } }