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

faster rand(UInt64) and rand(UInt128) #9083

Merged
merged 2 commits into from
Nov 20, 2014
Merged

faster rand(UInt64) and rand(UInt128) #9083

merged 2 commits into from
Nov 20, 2014

Conversation

rfourquet
Copy link
Member

On my machine, rand(UInt64) becomes 30%-40% faster, and rand(UInt128) about 110% faster.

The function rand_ui32 is removed, and rand_ui_52_raw, which consumes
one Float64 like rand_ui32, is used instead in the implementation of
rand{T<:IntTypes}(::Type{T}).
Consequently, rand(UInt128) consumes only 3 random Float64 instead of 4.
It seems that rand(UInt64) is also slightly faster.
A function reserve(::MersenneTwister) is called before rand_inbounds:
so only one bound check is done instead of two (resp. three) for UInt64
(resp. UInt128).
ViralBShah added a commit that referenced this pull request Nov 20, 2014
faster rand(UInt64) and rand(UInt128)
@ViralBShah ViralBShah merged commit cefe1f0 into master Nov 20, 2014
@rfourquet rfourquet deleted the rf/rand-fast128 branch November 21, 2014 08:47
@ViralBShah ViralBShah added the randomness Random number generation and the Random stdlib label Nov 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
randomness Random number generation and the Random stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants