daily
This commit is contained in:
@@ -76,22 +76,18 @@ namespace StgSharp.Mathematics
|
||||
package->ElementSize = sizeof(T);
|
||||
package->ComputeMode = 3;
|
||||
|
||||
if ((c3 | c4) > 0) { } else
|
||||
{
|
||||
int
|
||||
small_4_size = c4 / LargeWrapCount,
|
||||
large_4_size = small_4_size + 1,
|
||||
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 < large_4_count; i++) { }
|
||||
int
|
||||
small_4_size = c4 / LargeWrapCount,
|
||||
large_4_size = small_4_size + 1,
|
||||
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;
|
||||
|
||||
// TODO maybe a task slice method is good?
|
||||
}
|
||||
for (int i = 0; i < SmallWraps.Length; i++) { }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,20 +58,20 @@ namespace StgSharp.Mathematics
|
||||
|
||||
private static Thread[] _threads;
|
||||
private static readonly (int a, int b)[] LookupTable = [
|
||||
(1, 1),
|
||||
(0, 2),
|
||||
(3, 0),
|
||||
(2, 1),
|
||||
(1, 2),
|
||||
(0, 3),
|
||||
(3, 1),
|
||||
(2, 2),
|
||||
(1, 3),
|
||||
(0, 4),
|
||||
(3, 2),
|
||||
(2, 3),
|
||||
(1, 4),
|
||||
(0, 5),
|
||||
(1, 1), // 7
|
||||
(0, 2), // 8 (no non-zero solution)
|
||||
(3, 0), // 9 (no non-zero solution)
|
||||
(2, 1), // 10
|
||||
(1, 2), // 11
|
||||
(0, 3), // 12 (no non-zero solution)
|
||||
(3, 1), // 13
|
||||
(2, 2), // 14
|
||||
(1, 3), // 15
|
||||
(4, 1), // 16
|
||||
(3, 2), // 17
|
||||
(2, 3), // 18
|
||||
(1, 4), // 19
|
||||
(4, 2), // 20
|
||||
];
|
||||
private static bool _meaningful;
|
||||
|
||||
@@ -100,13 +100,14 @@ namespace StgSharp.Mathematics
|
||||
if (c < 7) {
|
||||
return (0, 0);
|
||||
}
|
||||
c -= 7;
|
||||
int c_prime = c / 14;
|
||||
int d = c % 14;
|
||||
|
||||
(int a_prime, int b_prime) = LookupTable[d];
|
||||
int t = c - 7;
|
||||
int k = t / 14;
|
||||
int d = t % 14;
|
||||
|
||||
return (a_prime + c_prime, b_prime + c_prime);
|
||||
(int a0, int b0) = LookupTable[d];
|
||||
|
||||
return (a0 + (2 * k), b0 + (2 * k));
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
@@ -129,13 +130,15 @@ namespace StgSharp.Mathematics
|
||||
{
|
||||
SmallWraps = [ new MatrixParallelWrap(0, count, true) ];
|
||||
LargeWraps = [];
|
||||
(LargeWrapCount, SmallWrapCount) = (1, 0);
|
||||
(LargeWrapCount, SmallWrapCount) = (0, 1);
|
||||
LeaderHandle = new MatrixParallelWrap.Handle(0, SmallWraps[0]);
|
||||
} else
|
||||
{
|
||||
count = 4;
|
||||
LargeWraps = [ new MatrixParallelWrap(0, count, true) ];
|
||||
SmallWraps = [];
|
||||
(LargeWrapCount, SmallWrapCount) = (0, 1);
|
||||
(LargeWrapCount, SmallWrapCount) = (1, 0);
|
||||
LeaderHandle = new MatrixParallelWrap.Handle(0, LargeWraps[0]);
|
||||
}
|
||||
} else if (count == 6)
|
||||
{
|
||||
@@ -145,11 +148,12 @@ namespace StgSharp.Mathematics
|
||||
];
|
||||
LargeWraps = [];
|
||||
(LargeWrapCount, SmallWrapCount) = (0, 2);
|
||||
LeaderHandle = new MatrixParallelWrap.Handle(0, SmallWraps[0]);
|
||||
} else
|
||||
{
|
||||
(int _3wrap, int _4wrap) = FastDecompose(count);
|
||||
LargeWraps = new MatrixParallelWrap[ _4wrap];
|
||||
SmallWraps = new MatrixParallelWrap[ _3wrap];
|
||||
LargeWraps = new MatrixParallelWrap[_4wrap];
|
||||
SmallWraps = new MatrixParallelWrap[_3wrap];
|
||||
int id = 0;
|
||||
for (int idx = 0; idx < _3wrap; idx++, id += 3) {
|
||||
SmallWraps[idx] = new MatrixParallelWrap(idx, 3, id == 0);
|
||||
@@ -157,8 +161,8 @@ namespace StgSharp.Mathematics
|
||||
for (int idx = 0; idx < _3wrap + _4wrap; idx++, id += 4) {
|
||||
LargeWraps[idx] = new MatrixParallelWrap(id, 4, id == 0);
|
||||
}
|
||||
LeaderHandle = new MatrixParallelWrap.Handle(0, _3wrap == 0 ? LargeWraps[0] : SmallWraps[0]);
|
||||
}
|
||||
LeaderHandle = new MatrixParallelWrap.Handle(0, _wraps[0]);
|
||||
LeaderTask = LeaderHandle.Wrap.GetWorkerTaskQueue(0);
|
||||
IsInitialized = true;
|
||||
}
|
||||
@@ -192,7 +196,10 @@ namespace StgSharp.Mathematics
|
||||
public static void SetAllWrap()
|
||||
{
|
||||
ResetThreadCount();
|
||||
foreach (MatrixParallelWrap item in _wraps) {
|
||||
foreach (MatrixParallelWrap item in SmallWraps) {
|
||||
item.SchedulerReset.Set();
|
||||
}
|
||||
foreach (MatrixParallelWrap item in LargeWraps) {
|
||||
item.SchedulerReset.Set();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user