Merge pull request #95 from mlemanczyk/codex/modify-evenperfectbitscanner-to-skip-candidates

Skip previously excluded by-divisor candidates
This commit is contained in:
Marek Lemańczyk authored and GitHub committed 2025-09-29 14:46:53 +02:00
commit e9270d16f3
1 file changed
+23
+23
View File
@@ -1,4 +1,5 @@
using System.Buffers;
using System.Collections.Generic;
using System.Globalization;
using System.Numerics;
using System.Runtime.CompilerServices;
@@ -36,6 +37,7 @@ internal static class Program
private static UInt128 _divisor;
private static MersenneNumberDivisorGpuTester? _divisorTester;
private static IMersenneNumberDivisorByDivisorTester? _byDivisorTester;
private static Dictionary<ulong, (bool DetailedCheck, bool PassedAllTests)>? _byDivisorPreviousResults;
private static ulong? _orderWarmupLimitOverride;
private static unsafe delegate*<ulong, ref ulong, ulong> _transformP;
private static long _state;
@@ -588,6 +590,9 @@ internal static class Program
}
Dictionary<ulong, (bool DetailedCheck, bool PassedAllTests)>? previousResults = useByDivisor ? new Dictionary<ulong, (bool DetailedCheck, bool PassedAllTests)>() : null;
_byDivisorPreviousResults = previousResults;
if (File.Exists(ResultsFileName))
{
Console.WriteLine("Processing previous results...");
@@ -597,6 +602,11 @@ internal static class Program
{
_primeCount++;
}
if (previousResults is not null)
{
previousResults[p] = (detailedCheck, passedAllTests);
}
});
}
else
@@ -772,6 +782,8 @@ internal static class Program
bool searched = false;
bool detailed = false;
ulong allowedMax = 0UL;
Dictionary<ulong, (bool DetailedCheck, bool PassedAllTests)>? previousResults = _byDivisorPreviousResults;
int skippedByPreviousResults = 0;
_byDivisorPrecheckOnly = true;
ulong startPrime = _byDivisorStartPrime;
@@ -784,6 +796,12 @@ internal static class Program
continue;
}
if (previousResults is not null && previousResults.TryGetValue(prime, out var previousResult) && !previousResult.PassedAllTests)
{
skippedByPreviousResults++;
continue;
}
if (!IsEvenPerfectCandidate(prime, divisorCyclesSearchLimit, out searched, out detailed))
{
PrintResult(prime, searched, detailed, false);
@@ -811,6 +829,11 @@ internal static class Program
_byDivisorPrecheckOnly = false;
if (skippedByPreviousResults > 0)
{
Console.WriteLine($"Skipped {skippedByPreviousResults.ToString(CultureInfo.InvariantCulture)} primes excluded by previous results.");
}
if (states.Count == 0)
{
if (applyStartPrime)