Repository navigation
Montgomery multiplication for the jumps of the MWCX generators - #176
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #176 +/- ##
========================================
Coverage 96.20% 96.20%
========================================
Files 130 130
Lines 8488 8490 +2
========================================
+ Hits 8166 8168 +2
Misses 322 322
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
The failures of the clang 3.6 and clang 3.7 jobs are unrelated to this PR: all the errors are in |
mborland
left a comment
There was a problem hiding this comment.
Looks good to me! Thanks as always. I will handle the failing clang jobs post merge.
Following up on #171,
discard()andjump()of the MWCX generators now multiply modulo m with Montgomery's method on 32-bit limbs, instead of shift-and-add. The idea comes from the implementation of these generators in NVIDIA's CCCL (NVIDIA/cccl#12590), for which Rory Mitchell suggested it; the reference implementation now uses it, too. The results are unchanged.On an x86-64 machine (Xeon E-2388G) with GCC 16.2 and Clang 23.1,
jump(1, 64)ofmwc128xgoes from 47–68 µs to 1.4–1.6 µs, anddiscard(1 << 40)from 13 µs to 0.9–1.0 µs; overall, jumps are from 6 to 50 times faster, depending on the generator, the distance and the compiler. As jumping is now much cheaper, the threshold below whichdiscard()steps the generator goes down from 4096, 16384 and 65536 steps (for one, two and three 64-bit words of state) to 128, 512 and 1152, which is close to the measured break-even point.