Enable residue-aware GPU sieve in PrimeTester

This commit is contained in:
Marek Lemańczyk committed 2025-10-28 18:39:18 +01:00
1 parent 3d43d52f2e
commit c53966e481
7 files changed
+359 -168

No files matched your search

@@ -17,6 +17,10 @@ public class PrimeTesterIsPrimeTests
[InlineData(97UL, true)]
[InlineData(133UL, false)]
[InlineData(137UL, true)]
[InlineData(143UL, false)]
[InlineData(199UL, true)]
[InlineData(209UL, false)]
[InlineData(403UL, false)]
[InlineData(341UL, false)]
public void IsPrime_returns_expected_results(ulong n, bool expected)
{
@@ -25,6 +29,20 @@ public class PrimeTesterIsPrimeTests
tester.IsPrime(n, CancellationToken.None).Should().Be(expected);
}
[Theory]
[Trait("Category", "Fast")]
[InlineData(139UL, true)]
[InlineData(189UL, false)]
[InlineData(193UL, true)]
[InlineData(279UL, false)]
public void IsPrimeGpu_uses_residue_specific_tables(ulong n, bool expected)
{
GpuContextPool.ForceCpu = false;
var tester = new PrimeTester();
tester.IsPrimeGpu(n, CancellationToken.None).Should().Be(expected);
}
[Fact]
[Trait("Category", "Fast")]
public void IsPrimeGpu_falls_back_to_cpu_when_forced()