Compare commits

...
@@ -80,9 +80,9 @@ public sealed class MersenneNumberDivisorByDivisorCpuTester : IMersenneNumberDiv
return true; return true;
} }
ulong processedCount; ulong processedCount = 0UL;
ulong lastProcessed; ulong lastProcessed = 0UL;
bool processedAll; bool processedAll = false;
bool composite = CheckDivisors( bool composite = CheckDivisors(
prime, prime,
@@ -238,20 +238,19 @@ public sealed class MersenneNumberDivisorByDivisorCpuTester : IMersenneNumberDiv
} }
} }
if (divisorCycle != 0 && divisorCycle == prime) if (divisorCycle == prime)
{ {
processedAll = true; // A cycle equal to the tested exponent (which is prime in this path)
return true; // guarantees that the candidate divides the corresponding Mersenne
} // number because the order of 2 modulo the divisor is exactly p.
else if (divisorCycle == 0) processedAll = true;
{ return true;
Console.WriteLine($"Divisor cycle wasn't calculated for ${prime}"); }
}
// if (divisorCycle != 0UL && CheckDivisor(prime, divisorCycle, divisorData) != 0) if (divisorCycle == 0UL)
// { {
// processedAll = true; Console.WriteLine($"Divisor cycle was not calculated for {prime}");
// return true; }
// }
} }
divisor += step; divisor += step;
@@ -299,9 +298,16 @@ public sealed class MersenneNumberDivisorByDivisorCpuTester : IMersenneNumberDiv
} }
ulong total = _lastStatusDivisor + processedCount; ulong total = _lastStatusDivisor + processedCount;
// TODO: Replace this modulo with the ring-buffer style counter (subtract loop) used in the fast CLI if (total >= interval)
// status benchmarks so we avoid `%` in this hot loop while still wrapping progress correctly. {
_lastStatusDivisor = total % interval; do
{
total -= interval;
}
while (total >= interval);
}
_lastStatusDivisor = total;
} }
private static ulong ComputeDivisorLimitFromMaxPrime(ulong maxPrime) private static ulong ComputeDivisorLimitFromMaxPrime(ulong maxPrime)