From d0c9389bcc910aeb883941da03f3b6ee8e5328af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Lema=C5=84czyk?= Date: Mon, 20 Oct 2025 13:58:04 +0200 Subject: [PATCH] Document GpuUInt128 MulMod shift benchmarking --- PerfectNumbers.Core/Gpu/GpuUInt128.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PerfectNumbers.Core/Gpu/GpuUInt128.cs b/PerfectNumbers.Core/Gpu/GpuUInt128.cs index 3ec4ed5..5700bc7 100644 --- a/PerfectNumbers.Core/Gpu/GpuUInt128.cs +++ b/PerfectNumbers.Core/Gpu/GpuUInt128.cs @@ -488,6 +488,9 @@ public struct GpuUInt128 : IComparable, IEquatable } else { + // Copy the low word into a temporary before shifting High; assigning directly + // regressed the GpuUInt128MulMod benchmarks (HighWordModulus 6.45 -> 7.38 us, + // MixedMagnitude 4.99 -> 6.24 us) with InvocationCount=16, IterationCount=3. ulong newLow = (multiplier.Low >> 1) | (multiplier.High << 63); multiplier.High >>= 1; multiplier.Low = newLow;