Merge pull request #45 from mlemanczyk/codex/investigate-evenperfectbitscanner-output-errors

Align GPU prime sieve with CPU GCD heuristic
This commit is contained in:
Marek Lemańczyk authored and GitHub committed 2025-09-20 19:48:50 +02:00
commit 2f07b776c6
1 file changed
+4 -1
+4 -1
View File
@@ -255,13 +255,16 @@ public sealed class PrimeTester(bool useInternal = false)
return; return;
} }
// Early reject special gcd heuristic with floor(log2 n) if ((n % 10UL) == 1UL)
{
// Early reject special GCD heuristic with floor(log2 n)
ulong m = 63UL - (ulong)ILGPU.Algorithms.XMath.LeadingZeroCount(n); ulong m = 63UL - (ulong)ILGPU.Algorithms.XMath.LeadingZeroCount(n);
if (BinaryGcdGpu(n, m) != 1UL) if (BinaryGcdGpu(n, m) != 1UL)
{ {
results[index] = 0; results[index] = 0;
return; return;
} }
}
long len = smallPrimes.Length; long len = smallPrimes.Length;
for (int i = 0; i < len; i++) for (int i = 0; i < len; i++)