lua-users home
lua-l archive
Re: new PRNG's
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
] [
Date Index
] [
Thread Index
]
Subject
:
Re: new PRNG's
From
: Albert Chan <albertmcchan@
...
>
Date
: Wed, 9 May 2018 09:16:29 -0400
I tried to replace LuaJIT 2.0.5 lib_math.c with xoshiro256**, but
did not see any math.random speedup (against Tausworthe)
By swapping s[0] and s[1], and scramble with updated state, it
matched LuaJIT Tausworthe speed. (Note: it is still xoshiro256**)
LuaJIT, 1 billion math.random(), best of 3
49.2s Tausworthe: LuaJIT stock PRNG
50.1s. Xoshiro256**:
http://xoshiro.di.unimi.it/xoshiro256starstar.c
48.9s. Xoshiro256** (modified), lj_math_random_step() patch below
static inline uint64_t rotl(const uint64_t x, int k) {
return (x << k) | (x >> (64 - k));
}
LJ_NOINLINE uint64_t LJ_FASTCALL lj_math_random_step(RandomState *rs)
{
uint64_t *s = rs->gen; /* modifed xoshiro256** */
uint64_t t = s[0] << 17; /* s[0], s[1] swapped */
s[2] ^= s[1];
s[3] ^= s[0];
s[0] ^= s[2];
s[1] ^= s[3];
s[2] ^= t;
s[3] = rotl(s[3], 45);
uint64_t r = rotl(s[0] * 5, 7) * 9; /* scramble updated state */
return (r & U64x(000fffff,ffffffff)) | U64x(3ff00000,00000000);
}
Follow-Ups
:
Re: new PRNG's
,
Albert Chan
References
:
new PRNG's
,
Albert Chan
Re: new PRNG's
,
Albert Chan
Re: new PRNG's
,
KHMan
Re: new PRNG's
,
Roberto Ierusalimschy
Re: new PRNG's
,
KHMan
Re: new PRNG's
,
Roberto Ierusalimschy
Re: new PRNG's
,
KHMan
Re: new PRNG's
,
Roberto Ierusalimschy
Re: new PRNG's
,
Sergey Rozhenko
Re: new PRNG's
,
Roberto Ierusalimschy
Re: new PRNG's
,
Rodrigo Azevedo
Re: new PRNG's
,
Luiz Henrique de Figueiredo
Re: new PRNG's
,
Rodrigo Azevedo
Prev by Date:
Re: new PRNG's
Next by Date:
Re: A tiny matter of style
Previous by thread:
Re: new PRNG's
Next by thread:
Re: new PRNG's
Index(es):
Date
Thread
AltStyle
によって変換されたページ
(->オリジナル)
/
アドレス:
モード:
デフォルト
音声ブラウザ
ルビ付き
配色反転
文字拡大
モバイル