-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
<random>
: generate_canonical()
could avoid calling log2()
at runtime
#1964
Labels
Comments
Hi, if I understand this issue correctly, is the suggested solution comparing For example,
|
CaseyCarter
added a commit
to CaseyCarter/STL
that referenced
this issue
Dec 31, 2021
... to calculate parameters at compile-time for random engines with power-of-two range. This greatly improves debug codegen, and release codegen for compilers that do not constant fold `std::ceil` and/or `std::log2`. Fixes microsoft#1964.
CaseyCarter
added a commit
to CaseyCarter/STL
that referenced
this issue
Dec 31, 2021
... to calculate parameters at compile-time for random engines with power-of-two range. This greatly improves debug codegen, and release codegen for compilers that do not constant fold `std::ceil` and/or `std::log2`. Fixes microsoft#1964.
CaseyCarter
added a commit
to CaseyCarter/STL
that referenced
this issue
Jan 1, 2022
... to calculate parameters at compile-time for random engines with power-of-two range. This greatly improves debug codegen, and release codegen for compilers that do not constant fold `std::ceil` and/or `std::log2`. Fixes microsoft#1964.
MattStephanson
added a commit
to MattStephanson/STL
that referenced
this issue
Jan 21, 2022
...up to 64 bits of entropy. Leave the original implementation for more bits and naughty generators (I'm looking at you, tr1) whose min and max functions aren't static. Fixes microsoft#1964. Alternative to microsoft#2452.
CaseyCarter
pushed a commit
that referenced
this issue
Feb 7, 2022
...up to 64 bits of entropy. Leave the original implementation for more bits and naughty generators (I'm looking at you, tr1) whose `min` and `max` functions aren't static. Fixes #1964.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gautham Beeraka reported a performance issue in
generate_canonical()
, where it callslog2()
:STL/stl/inc/random
Lines 248 to 259 in 4c862ee
For engines like
mt19937
andmt19937_64
, this is a really expensive way of computing32.0
and64.0
.Solving this in a completely general manner might be somewhat difficult, but perhaps we could simply special-case the Standard engines that are known to have a power-of-2 range.
The text was updated successfully, but these errors were encountered: