Removed useless status method
This commit is contained in:
1 parent
26567bbdaf
commit
a171e57353
1 file changed
+15
-41
@@ -15,7 +15,6 @@ public sealed class MersenneNumberDivisorByDivisorGpuTester : IMersenneNumberDiv
|
|||||||
private readonly object _sync = new();
|
private readonly object _sync = new();
|
||||||
private ulong _divisorLimit;
|
private ulong _divisorLimit;
|
||||||
private bool _isConfigured;
|
private bool _isConfigured;
|
||||||
private ulong _lastStatusDivisor;
|
|
||||||
private bool _useDivisorCycles;
|
private bool _useDivisorCycles;
|
||||||
|
|
||||||
public readonly struct MontgomeryDivisorData(ulong modulus, ulong nPrime, ulong montgomeryOne, ulong montgomeryTwo)
|
public readonly struct MontgomeryDivisorData(ulong modulus, ulong nPrime, ulong montgomeryOne, ulong montgomeryTwo)
|
||||||
@@ -62,7 +61,6 @@ public sealed class MersenneNumberDivisorByDivisorGpuTester : IMersenneNumberDiv
|
|||||||
lock (_sync)
|
lock (_sync)
|
||||||
{
|
{
|
||||||
_divisorLimit = ComputeDivisorLimitFromMaxPrime(maxPrime);
|
_divisorLimit = ComputeDivisorLimitFromMaxPrime(maxPrime);
|
||||||
_lastStatusDivisor = 0UL;
|
|
||||||
_isConfigured = true;
|
_isConfigured = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,14 +123,6 @@ public sealed class MersenneNumberDivisorByDivisorGpuTester : IMersenneNumberDiv
|
|||||||
gpuLease.Dispose();
|
gpuLease.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (processedCount > 0UL)
|
|
||||||
{
|
|
||||||
lock (_sync)
|
|
||||||
{
|
|
||||||
UpdateStatusUnsafe(processedCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (composite)
|
if (composite)
|
||||||
{
|
{
|
||||||
divisorsExhausted = true;
|
divisorsExhausted = true;
|
||||||
@@ -181,6 +171,7 @@ public sealed class MersenneNumberDivisorByDivisorGpuTester : IMersenneNumberDiv
|
|||||||
Span<byte> hitsSpan;
|
Span<byte> hitsSpan;
|
||||||
ArrayView1D<MontgomeryDivisorData, Stride1D.Dense> divisorView;
|
ArrayView1D<MontgomeryDivisorData, Stride1D.Dense> divisorView;
|
||||||
ArrayView1D<byte, Stride1D.Dense> hitsView;
|
ArrayView1D<byte, Stride1D.Dense> hitsView;
|
||||||
|
DivisorCycleCache divisorCyclesCache = DivisorCycleCache.Shared;
|
||||||
|
|
||||||
while (divisor <= allowedMax)
|
while (divisor <= allowedMax)
|
||||||
{
|
{
|
||||||
@@ -195,18 +186,20 @@ public sealed class MersenneNumberDivisorByDivisorGpuTester : IMersenneNumberDiv
|
|||||||
processedCount++;
|
processedCount++;
|
||||||
|
|
||||||
bool includeDivisor = true;
|
bool includeDivisor = true;
|
||||||
if (useCycles)
|
if (useCycles)
|
||||||
{
|
{
|
||||||
using DivisorCycleCache.Lease cycleLease = DivisorCycleCache.Shared.Acquire(currentDivisor);
|
DivisorCycleCache.Lease cycleLease = divisorCyclesCache.Acquire(currentDivisor);
|
||||||
ulong cycle = cycleLease.GetCycle(currentDivisor);
|
ulong cycle = cycleLease.GetCycle(currentDivisor);
|
||||||
if (cycle == 0UL)
|
if (cycle == 0UL)
|
||||||
{
|
{
|
||||||
requiresCycleKernelCheck = true;
|
requiresCycleKernelCheck = true;
|
||||||
}
|
}
|
||||||
else if (prime % cycle != 0UL)
|
else if (prime % cycle != 0UL)
|
||||||
{
|
{
|
||||||
includeDivisor = false;
|
includeDivisor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cycleLease.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeDivisor)
|
if (includeDivisor)
|
||||||
@@ -323,25 +316,6 @@ public sealed class MersenneNumberDivisorByDivisorGpuTester : IMersenneNumberDiv
|
|||||||
return Math.Min((1UL << (int)(prime - 1UL)) - 1UL, divisorLimit);
|
return Math.Min((1UL << (int)(prime - 1UL)) - 1UL, divisorLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStatusUnsafe(ulong processedCount)
|
|
||||||
{
|
|
||||||
if (processedCount == 0UL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong interval = PerfectNumberConstants.ConsoleInterval;
|
|
||||||
if (interval == 0UL)
|
|
||||||
{
|
|
||||||
_lastStatusDivisor = 0UL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can we avoid the modulo calculation here? For the higher divisors it may become very expensive. Do we need to calculate the total, too?
|
|
||||||
ulong total = _lastStatusDivisor + processedCount;
|
|
||||||
_lastStatusDivisor = total % interval;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void CheckKernel(Index1D index, ulong prime, byte useCycleChecks, ArrayView<MontgomeryDivisorData> divisors, ArrayView<byte> hits)
|
private static void CheckKernel(Index1D index, ulong prime, byte useCycleChecks, ArrayView<MontgomeryDivisorData> divisors, ArrayView<byte> hits)
|
||||||
{
|
{
|
||||||
MontgomeryDivisorData divisor = divisors[index];
|
MontgomeryDivisorData divisor = divisors[index];
|
||||||
|
|||||||
Reference in new issue
Block a user