-
Notifications
You must be signed in to change notification settings - Fork 1
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
Added Machine-Prime, simplified nearest_prime #84
Conversation
Added the low-memory variant of Machine-prime (using a modified BPSW test) as an optional dependency. The Criterion benchmark shows that it is approximately 16x faster than the existing version. Simplified the next and previous_prime functions
53a50a7
into
JSorngard:machine_prime_integration
The difference in benchmark is interesting. I consistently get 16x speed up. But that seems to be because I wrote/optimised it on lower-end hardware. I wonder if the trial division is somehow getting vectorised on your machine. Either way the worst-case is equivalent to only 2.5 fermat tests, so it'll beat it out pretty much regardless of what compiler optimisations are done. On i5-5300u processor time 12.021 ms -> 0.666 ms Throughput 0.831M /s -> 15M/s |
Interesting :o My CPU is a 5800X3D, but I don't think the extra cache should help in this situation, it must be something else. Regardless, I appreciate your excellent contribution! |
Added the low-memory variant of Machine-prime (using a modified BPSW test) as an optional dependency. The Criterion benchmark shows that it is approximately 16x faster than the existing version. Machine-Prime's other variants are faster still but require more memory and this is already a memory-intensive library.
MP is no-std and usable in const functions as well.
Simplified the next_prime and previous_prime functions