- Notifications
You must be signed in to change notification settings - Fork1.6k
<random>: Implement Lemire's fast integer generation#3012
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
<random>: Implement Lemire's fast integer generation#3012
Uh oh!
There was an error while loading.Please reload this page.
Conversation
<random>: Implement Lemire's fast integer generationlemire commentedAug 9, 2022
These results are interesting... |
frederick-vs-ja left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I suppose that this is a great step towardsDevCom-879048.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
statementreply commentedAug 15, 2022
I added xoshiro256** and xoshiro128** for comparison, which are fast and have small states. Benchmark results onMattStephanson@0156b8d (reformatted): AMD Ryzen 7 5700X, x86AMD Ryzen 7 5700X, x64Intel Core i5-8400, x86Intel Core i5-8400, x64 |
This comment was marked as resolved.
This comment was marked as resolved.
StephanTLavavej left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks, this approach looks good to me! (I skipped the int128 changes as I assume we'll want to land@frederick-vs-ja's#3036 first.)
The benchmark results look convincing enough to me, especially@statementreply's cases. 😻
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
MattStephanson commentedAug 19, 2022
Some of@StephanTLavavej's feedback affects codegen, so here are my updated benchmark results. I think they're pretty similar to what I originally posted. x86x64 |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
StephanTLavavej commentedSep 3, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This is a rich source of compiler bugs 😹, caused by dragging
No changes requested for this PR, but I'm going to pull it out of the current merge batch (where I speculatively/greedily tried to add it). |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
StephanTLavavej commentedSep 9, 2022
@JonCavesMSFT just fixed the non-modules bugs (yay! 😻) and the affected modules tests can be skipped. (I don't believe that Standard Library Header Units or the named Standard Library Modules will be affected, as we're already dragging |
strega-nil-ms commentedSep 12, 2022
I've added the benchmark code to the repo; thanks! |
StephanTLavavej commentedSep 12, 2022
@strega-nil-ms Was the force-push here unintentional? |
StephanTLavavej commentedSep 12, 2022
I see, a damaged commit was amended, but the history wasn't further rewritten. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
StephanTLavavej commentedSep 12, 2022
@strega-nil-ms I pushed minor changes to the benchmark after validating that it still builds and runs properly. Thanks for adding it! |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
strega-nil-ms left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
barcharcraz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This seems correct to me, as far as my understanding of goes. I think this is ready.
StephanTLavavej commentedSep 20, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I've pushed a merge with ✅ I double-checked that this PR should have no impact on modules. |
StephanTLavavej commentedSep 22, 2022
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
StephanTLavavej commentedSep 22, 2022
Thank you for improving the performance of This will be available in either VS 2022 17.5 Preview 1 or Preview 2 (depending on internal merge logistics; the Changelog will record our current expectation). |
Co-authored-by: Nicole Mazzuca <mazzucan@outlook.com>Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>

Uh oh!
There was an error while loading.Please reload this page.
Implements@lemire's "Fast Random Integer Generation in an Interval",https://dl.acm.org/doi/10.1145/3230636 andhttps://arxiv.org/abs/1805.10941.Fixes#178.
I'm not happy with the x86 or LCG performance, but I've been tinkering with it for weeks and haven't been able to improve it further. I'm using a Surface Pro 8, i5-1135G7. It's plugged in and set to "Best Performance", but I'm otherwise not very knowledgeable about how to run good microbenchmarks. If anyone has any thoughts, I'd love to hear them.
Benchmark code
Benchmark results
x86
x64