Ensure GPU residue copies are synchronized and cover high divisor sets

This commit is contained in:
Marek Lemańczyk committed 2025-09-20 22:49:37 +02:00
1 parent 633c94906a
commit 7449f146d9
7 files changed
+215 -2

No files matched your search

@@ -19,6 +19,38 @@ public class MersenneNumberResidueIntegrationTests
yield return new object[] { 4 };
}
[Theory]
[InlineData(107UL)]
[InlineData(127UL)]
[Trait("Category", "Fast")]
public void Residue_gpu_mode_handles_large_residue_set_counts_for_known_primes(ulong exponent)
{
var tester = new MersenneNumberTester(
useIncremental: false,
useOrderCache: false,
kernelType: GpuKernelType.Pow2Mod,
useModuloWorkaround: false,
useOrder: false,
useGpuLucas: false,
useGpuScan: true,
useGpuOrder: true,
useResidue: true,
maxK: (UInt128)1_024UL,
residueDivisorSets: (UInt128)1_024UL);
try
{
bool isPrime = tester.IsMersennePrime(exponent, out bool divisorsExhausted);
isPrime.Should().BeTrue();
divisorsExhausted.Should().BeTrue();
}
finally
{
GpuContextPool.DisposeAll();
}
}
[Theory]
[MemberData(nameof(ResidueThreadCounts))]
[Trait("Category", "Fast")]