Additional checks will be skipped in bydivisor mode to speed up calculations. Console output extended.
This commit is contained in:
1 parent
562d2adc3e
commit
d117921c3a
2 files changed
+11
-1
No files matched your search
@@ -1440,7 +1440,7 @@ internal static class Program
|
||||
}
|
||||
|
||||
// Fast residue-based composite check for p using small primes
|
||||
if (!_useDivisor && IsCompositeByResidues(p))
|
||||
if (!_useDivisor && !_useByDivisorMode && IsCompositeByResidues(p))
|
||||
{
|
||||
searchedMersenne = false;
|
||||
detailedCheck = false;
|
||||
@@ -1450,6 +1450,8 @@ internal static class Program
|
||||
|
||||
// If primes-device=gpu, route p primality through GPU-assisted sieve (optional MR later)
|
||||
// TODO: Add deterministic Miller–Rabin rounds in GPU path for 64-bit range.
|
||||
if (!_useByDivisorMode)
|
||||
{
|
||||
bool isPrimeP = GpuContextPool.ForceCpu
|
||||
? PrimeTesters.Value!.IsPrime(p, CancellationToken.None)
|
||||
: PrimeTesters.Value!.IsPrimeGpu(p, CancellationToken.None);
|
||||
@@ -1458,6 +1460,7 @@ internal static class Program
|
||||
_lastCompositeP = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
searchedMersenne = true;
|
||||
if (_useByDivisorMode)
|
||||
|
||||
@@ -274,12 +274,19 @@ public sealed class MersenneNumberDivisorByDivisorGpuTester
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
int consoleStatus = 0;
|
||||
while (offset < primes.Length)
|
||||
{
|
||||
int batchSize = Math.Min(_owner._gpuBatchSize, primes.Length - offset);
|
||||
Span<ulong> primeSpan = _primesHost.AsSpan(0, batchSize);
|
||||
primes.Slice(offset, batchSize).CopyTo(primeSpan);
|
||||
|
||||
if (++consoleStatus == PerfectNumberConstants.ConsoleInterval)
|
||||
{
|
||||
Console.WriteLine($"...processed by-divisor candidate = {primes[0]}");
|
||||
consoleStatus = 0;
|
||||
}
|
||||
|
||||
var primesView = _primesBuffer.View.SubView(0, batchSize);
|
||||
var hitsView = _hitsBuffer.View.SubView(0, batchSize);
|
||||
|
||||
|
||||
Reference in new issue
Block a user