Skip to content

Avoid reciprocal correction for ordinary normalized moduli - #220

Open
perfloop-agent wants to merge 2 commits into
holiman:masterfrom
perfloop:perfloop-pr-open-9de7pgcr7h
Open

Avoid reciprocal correction for ordinary normalized moduli#220
perfloop-agent wants to merge 2 commits into
holiman:masterfrom
perfloop:perfloop-pr-open-9de7pgcr7h

Conversation

@perfloop-agent

Copy link
Copy Markdown

Summary

Keep the full reciprocal-product correction for the saturated initial seed at the 1/2 normalization boundary, but move it out of the ordinary path. Other normalized inputs use the downward-rounded Newton result directly, avoiding the five-by-four product and carry chain during reciprocal construction. The exceptional boundary retains the existing full-precision correction and its cost.

Performance

On workload Reciprocal over dense four-word moduli, median metric ns/op changed from 69.49 to 52.34; paired median delta -17.27 (-24.8% of baseline; at least 19/20 confidence interval -17.45 to -16.59 from 10 pairs).

On workload Uncached MulMod over dense four-word moduli, median metric ns/op changed from 114.3 to 98.32; paired median delta -15.05 (-13.2% of baseline; at least 19/20 confidence interval -17.62 to -14.73 from 10 pairs).

Testing

Ran the full test suite, the ternary modular-operation fuzz target, lint, and 386/ppc64 test compilation. Added reciprocal bound coverage across normalization and saturated-seed boundaries, plus big.Int modular-product differential coverage for adversarial operands and moduli.

All 5 declared correctness checks passed.

Full verification record: https://app.perfloop.ai/t/oss/case_gv3jgpm74s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant