Comments (11)
This seems to work as desired on 0.5 (with -O3), but not on 0.4
function rotr(x,y)
s = sizeof(x) << 3
(x >> (y % s)) | (x << (-y % s))
end
from randomnumbers.jl.
Thanks, Simon. The former one seems very nice, I'll use this.
BTW there's a typo in the codes that it should be %4 = sub i64 63, %1
from randomnumbers.jl.
Why would it be 63, not 64?
from randomnumbers.jl.
I would suggest the latter one: the generality is well worth it, and hopefully 0.5 should be released by the time we're performance tuning. llvmcall is usually the last resort sort of thing.
from randomnumbers.jl.
Oh I just found myself wrong.
Okay, it's reasonable to take the second function.
from randomnumbers.jl.
Yesterday did you mean that I should just write
@inline function pcg_rotr(x::UIntTypes, y::UIntTypes)
s = sizeof(x) << 3
(x >> (y % s)) | (x << (-y % s))
end
instead of the current @eval
form?
from randomnumbers.jl.
Yes, exactly: @eval
gets you nothing in this case (each combination of concrete UInt
types will still be JIT-ed).
You could even do this for a lot of the other functions, as it seems like the constants can mostly be computed (and so will be evaluated at compile time).
from randomnumbers.jl.
e.g. for XSH RR, you could include in the function
s = sizeof(state) << 3
t = trailing_zeros(s)-1 # log2(s)-1
p1 = (s>>1 + t)>>1
p2 = s>>1 - t
p3 = s-t
which the JIT is smart enough to evaluate as constants.
from randomnumbers.jl.
Though for 128 bits, this gives a p1
as 35, not 29 as in your code: where did you get the constants from?
from randomnumbers.jl.
I copied the constants in the PCG sources. http://www.pcg-random.org/download.html
from randomnumbers.jl.
Ah, I see. I opened an issue here:
imneme/pcg-c-basic#7
I guess we see what the author says.
from randomnumbers.jl.
Related Issues (20)
- zero seeds give zeros HOT 4
- Documentation link on README is broken atm? HOT 1
- Please consider implementing xoshiro256** (and/or xoshiro256+) HOT 4
- Move Random123 to a separate package? HOT 5
- ArgumentError: Package RandomNumbers does not have Requires in its dependencies: HOT 8
- Wrong implementation of Mersenne Twister HOT 2
- Storing RNG state HOT 2
- New release HOT 5
- FYI: Xoroshiro128Plus 2.9 times slower in real-world app (and Julia's default only 1.9 times slower) HOT 4
- chaotic prng
- Testing PRNGs to help in the selection of high-quality PRNGs
- possible test failure in upcoming Julia version 1.5
- Xoroshiro128Plus slows down relative to Base MT with increasing sample size HOT 1
- Very cheap PRNG HOT 8
- Why is the Mersenne Twister in Base faster? HOT 1
- Proposal: randfloat() for sampling from _all_ floats in [0,1)? HOT 15
- Xorshift128Plus has several catastrophically bad seeds HOT 4
- TagBot trigger issue HOT 23
- Ambiguity error with complex numbers HOT 1
- Docs build failure
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from randomnumbers.jl.