Align Lucas-Lehmer GPU helpers with windowed pow2 guidance

This commit is contained in:
Marek Lemańczyk committed 2025-10-20 18:37:15 +02:00
1 parent 82e44e3f3f
commit 360a31bd54
2 files changed
+4 -15

No files matched your search

+2 -12
View File
@@ -1020,18 +1020,8 @@ public struct GpuUInt128 : IComparable<GpuUInt128>, IEquatable<GpuUInt128>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ulong ShiftLeftByNativeChunk(ulong value, ulong modulus)
{
// TODO: Collapse this eight-step shift ladder into the ProcessEightBitWindows helper once it lands so
// we reuse the precomputed window residues instead of emitting `% modulus` after every shift.
value = (value << 1) % modulus;
value = (value << 1) % modulus;
value = (value << 1) % modulus;
value = (value << 1) % modulus;
value = (value << 1) % modulus;
value = (value << 1) % modulus;
value = (value << 1) % modulus;
value = (value << 1) % modulus;
return value;
// Multiply by 2^NativeModuloChunkBits in one pass so the native-modulo path avoids eight `%` reductions.
return MulMod64(value, 1UL << NativeModuloChunkBits, modulus);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]