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

xoshiro256++ implementation in task.c #42150

Closed
stefan-zobel opened this issue Sep 7, 2021 · 6 comments
Closed

xoshiro256++ implementation in task.c #42150

stefan-zobel opened this issue Sep 7, 2021 · 6 comments
Labels
domain:randomness Random number generation and the Random stdlib
Milestone

Comments

@stefan-zobel
Copy link

stefan-zobel commented Sep 7, 2021

uint64_t t = s0 << 17;

Shouldn't this be s1 as in

uint64_t t = s1 << 17; ?

Note: s1, not s0

See Fig. 5 ("C code for a xoshiro256+/xoshiro256++/xoshiro256** generator") on page 6 in the Blackman / Vigna paper : https://arxiv.org/pdf/1805.01407.pdf

@stevengj stevengj added the domain:randomness Random number generation and the Random stdlib label Sep 7, 2021
@stevengj
Copy link
Member

stevengj commented Sep 7, 2021

cc @chethega and @rfourquet, who wrote this code.

@GregPlowman
Copy link
Contributor

GregPlowman commented Sep 8, 2021

Also, implementation in task.c seems inconsistent with stdlib version:

uint64_t res = ((tmp << 23) | (tmp >> 41)) + s0;

res = tmp << 23 | tmp >> 41

Shouldn't this be:

res = (tmp << 23 | tmp >> 41) + s0

See ref: https://prng.di.unimi.it/xoshiro256plusplus.c

@PallHaraldsson
Copy link
Contributor

PallHaraldsson commented Sep 8, 2021

It seems obvious that both the implementations are wrong (while fixes trivial), so this needs to be added to 1.7 milestone.

PallHaraldsson added a commit to PallHaraldsson/julia that referenced this issue Sep 8, 2021
See JuliaLang#42150. SIMD code seems to have same error, not considered here.
@vchuravy vchuravy added this to the 1.7 milestone Sep 8, 2021
@bjarthur
Copy link
Contributor

bjarthur commented Sep 8, 2021

@vtjnash
Copy link
Sponsor Member

vtjnash commented Sep 8, 2021

This is not undefined behavior, so unrelated. There is perhaps a fast-fill array method that is vectorized for longer arrays? I am not sure if it was supposed to show a difference for simple sequences like that.

@JeffBezanson
Copy link
Sponsor Member

fixed by #42201

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:randomness Random number generation and the Random stdlib
Projects
None yet
Development

No branches or pull requests

8 participants