Confirm windowed pow2 usage across GPU kernels

This commit is contained in:
Marek Lemańczyk committed 2025-10-20 18:37:08 +02:00
1 parent 7cbc27d6c3
commit 82e44e3f3f
6 files changed
+8 -20

No files matched your search

@@ -96,9 +96,7 @@ internal static class IncrementalKernels
}
ulong phi64 = phi.Low;
// TODO: Replace these Pow2Mod calls with the ProcessEightBitWindows helper when the shared windowed
// scalar implementation lands; benchmarks showed the windowed kernel trimming per-divisor runtime by ~2.4×.
if (GpuUInt128.Pow2Mod(phi64, in readOnlyQ) != GpuUInt128.One)
if (GpuUInt128.Pow2Mod(phi64, in readOnlyQ) != GpuUInt128.One) // Windowed pow2 keeps the totient check fast.
{
orders[index] = 0UL;
return;
@@ -194,9 +192,7 @@ internal static class IncrementalKernels
}
ulong phi64 = phi.Low;
// TODO: Upgrade this pow2mod order kernel to the ProcessEightBitWindows helper once available so GPU residue
// scans avoid the single-bit ladder that benchmarks found to be 2.3× slower on large exponents.
if (GpuUInt128.Pow2Mod(phi64, in readOnlyQ) != GpuUInt128.One)
if (GpuUInt128.Pow2Mod(phi64, in readOnlyQ) != GpuUInt128.One) // Windowed pow2 keeps the order probe aligned with benchmarks.
{
return;
}