Enable residue-aware GPU sieve in PrimeTester
This commit is contained in:
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()
|
||||
|
||||
Reference in new issue
Block a user