Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix limb count heuristics #803

Merged
merged 1 commit into from
May 21, 2020
Merged

Fix limb count heuristics #803

merged 1 commit into from
May 21, 2020

Conversation

jadephilipoom
Copy link
Collaborator

Fixes #801

Tests:

Compute @get_possible_limbs (2^448) [(2^224,1); (1,1)] 64. (* [8%nat; 10%nat; 13%nat] *)
Compute @get_possible_limbs (2^448) [(2^224,1); (1,1)] 32. (* [18%nat; 20%nat; 21%nat; 22%nat; 23%nat; 24%nat; 25%nat; 26%nat; 27%nat] *)
Compute @get_possible_limbs (2^480) [(2^240,1); (1,1)] 64. (* [8%nat; 10%nat; 11%nat; 12%nat; 13%nat; 14%nat; 15%nat] *)
Compute @get_possible_limbs (2^480) [(2^240,1); (1,1)] 32. (* [18%nat; 20%nat; 22%nat; 23%nat; 24%nat; 25%nat; 26%nat; 27%nat; 28%nat; 29%nat] *)
Compute @get_possible_limbs (2^192) [(2^64, 1); (1, 1)] 64. (* [4%nat; 5%nat] *)
Compute @get_possible_limbs (2^192) [(2^64, 1); (1, 1)] 64. (* [9%nat; 10%nat; 11%nat] *)

@jadephilipoom
Copy link
Collaborator Author

One note here: with the loose bounds multiplier set to 3, some nice possibilities (like 16-limb p448 on 32-bit) are excluded due to overflow. I double checked and it does indeed seem the bounds are too loose in that case (but not with the bounds multiplier set to 2).

Copy link
Collaborator

@JasonGross JasonGross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@JasonGross
Copy link
Collaborator

One note here: with the loose bounds multiplier set to 3, some nice possibilities (like 16-limb p448 on 32-bit) are excluded due to overflow. I double checked and it does indeed seem the bounds are too loose in that case (but not with the bounds multiplier set to 2).

This seems potentially like an argument in favor of #799 (cc @andres-erbsen )

@JasonGross
Copy link
Collaborator

Should we add test-cases for this?

@jadephilipoom
Copy link
Collaborator Author

jadephilipoom commented May 21, 2020 via email

@JasonGross
Copy link
Collaborator

Yes. I vote for just including a solinas multi-tap prime on our generated code tests

Oh, heh, I was thinking of doing tests for all of the primes. The first 40 (out of the 80 in the primes list) take about 30 seconds in native_compute, and about 240 seconds in vm_compute (@maximedenes might be interested in this speedup). Unfortunately doing all 80 is prohibitively expensive, but I think doing the first 40 in the native compiler is reasonable.

@jadephilipoom
Copy link
Collaborator Author

Does the first 40 include many multi-tap ones, though? iirc they were mostly towards the end of the list.

@JasonGross
Copy link
Collaborator

Oh, indeed, the multitap primes are the final 19. But we can do all of these primes in 2.027 seconds in the native compiler. So maybe we have as a test the first 30 and the last 19?

@jadephilipoom
Copy link
Collaborator Author

Sure, although keep in mind the primes with huge coefficients on their multi-taps are designed for Montgomery and might correctly not have any options for limb counts.

@JasonGross
Copy link
Collaborator

Hm, unfortunately, with this PR, the computation is much, much slower. So I guess we can't get all of them...

@JasonGross
Copy link
Collaborator

Btw, 2^205 - 45*2^198 - 1 is not listed as a montgomery-specific prime, but there are no options generated for it. This is the only one of the ones labeled "two or more taps" like this.

@JasonGross
Copy link
Collaborator

(All of the "two taps, golden ratio" primes get possibilities generated for them, though it takes 50s to generate all the possibilities)

@JasonGross JasonGross merged commit 493b5fd into master May 21, 2020
@JasonGross JasonGross deleted the fix_heuristics branch May 21, 2020 21:38
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.

get_possible_limbs thinks there are no valid limbs for 2^448 - 2^224 - 1
2 participants