merge and fix conflict

This commit is contained in:
Youmu Liu
2025-10-09 09:19:00 +08:00
2 changed files with 19 additions and 19 deletions
@@ -1,6 +1,6 @@
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// file="MatrixParallel.TaskPublic.cs" // file="MatrixParallel.Publish.cs"
// Project: StgSharp // Project: StgSharp
// AuthorGroup: Nitload Space // AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved. // Copyright (c) Nitload Space. All rights reserved.
@@ -76,18 +76,9 @@ namespace StgSharp.Mathematics
package->ElementSize = sizeof(T); package->ElementSize = sizeof(T);
package->ComputeMode = 3; package->ComputeMode = 3;
int int baseCount = columnCount / length,
small_4_size = c4 / LargeWrapCount, rem = columnCount % length;
large_4_size = small_4_size + 1, if (baseCount == 0) { }
small_3_size = c3 / LargeWrapCount,
large_3_size = small_3_size + 1;
int
large_4_count = c4 % LargeWrapCount,
small_4_count = LargeWrapCount - large_4_count,
large_3_count = c3 % LargeWrapCount,
small_3_count = LargeWrapCount - large_3_count;
for (int i = 0; i < SmallWraps.Length; i++) { }
} }
} }
@@ -56,6 +56,18 @@ namespace StgSharp.Mathematics
public static partial class MatrixParallel public static partial class MatrixParallel
{ {
// TODO
/*
* 目前认为应当按照如下方式进行调整:
* 1. 使用Queue进行线程束池化
* 2. 一次只能有一个线程进行发布活动(一次只能由一个线程持有)
* 3. 发布任务似乎应当分类进行,分类条件为q = n_task / n_thread
* 3.1 q=0时,不是全部任务束可以参与计算
* 3.2 q>0时,全部任务束可以参与计算
* 4. 后续分为a个q线程,b个q+1线程,然后分到线程束中,同时不保证束内任务同步
* 5. 仅可能保证线程间任务数量差异不超过512
*/
private static Thread[] _threads; private static Thread[] _threads;
private static readonly (int a, int b)[] LookupTable = [ private static readonly (int a, int b)[] LookupTable = [
(1, 1), // 7 (1, 1), // 7
@@ -142,10 +154,7 @@ namespace StgSharp.Mathematics
} }
} else if (count == 6) } else if (count == 6)
{ {
SmallWraps = [ SmallWraps = [ new MatrixParallelWrap(0, 3, true), new MatrixParallelWrap(3, 3, false) ];
new MatrixParallelWrap(0, 3, true),
new MatrixParallelWrap(3, 3, false)
];
LargeWraps = []; LargeWraps = [];
(LargeWrapCount, SmallWrapCount) = (0, 2); (LargeWrapCount, SmallWrapCount) = (0, 2);
LeaderHandle = new MatrixParallelWrap.Handle(0, SmallWraps[0]); LeaderHandle = new MatrixParallelWrap.Handle(0, SmallWraps[0]);
@@ -196,10 +205,10 @@ namespace StgSharp.Mathematics
public static void SetAllWrap() public static void SetAllWrap()
{ {
ResetThreadCount(); ResetThreadCount();
foreach (MatrixParallelWrap item in SmallWraps) { foreach (MatrixParallelWrap item in LargeWraps) {
item.SchedulerReset.Set(); item.SchedulerReset.Set();
} }
foreach (MatrixParallelWrap item in LargeWraps) { foreach (MatrixParallelWrap item in SmallWraps) {
item.SchedulerReset.Set(); item.SchedulerReset.Set();
} }
} }