Is SplitMix64 also recommended to seed 32-bit xoroshiro/xoshiro generators?

217 views
Skip to first unread message

k.grocho...@gmail.com

unread,
Jun 14, 2019, 11:46:19 AM6/14/19
to prng
64-bit multiplications to seed on a 32-bit CPU seems ridiculous. What method is instead recommended?

k.grocho...@gmail.com

unread,
Jun 14, 2019, 11:48:55 AM6/14/19
to prng
Not to mention, using a 64-bit seed and using SplitMix64 is fundamentally flawed in case of xoroshiro64* and xoroshiro64**.

david.j...@gmail.com

unread,
Jun 24, 2019, 12:08:26 AM6/24/19
to prng
On Saturday, 15 June 2019 01:48:55 UTC+10, k.groch...@gmail.com wrote:
> Not to mention, using a 64-bit seed and using SplitMix64 is fundamentally flawed in case of xoroshiro64* and xoroshiro64**.

I don't think there's any official method. Inventing your own SplitMix32 sounds plausible. Multipliers and increment odd, with a "random" looking mix of 0s and 1s, and shift counts close to half the word size, is probably good enough for this purpose.

Other reasonably good prngs that are not linear with respect to XOR are probably ok too. In the case of xoroshiro64**, i think you could likely get away with using xoroshiro64** to seed it, but carefully. But how to seed the first xoroshiro64** ? Seed in one state word, non-zero constant such as 42, or maybe 123456789, in the other, then iterate a few times throwing away the output. Then next 2 outputs into the state vector of the second xoroshiro64** . Then you're ready to go.

I *think* this works ok, but it's quite a while since i tested it. If you're trying for minimalism on some small 32 bit controller without multiply instruction, maybe something like that is the way to go.

Sebastiano Vigna

unread,
Jun 24, 2019, 3:01:37 AM6/24/19
to prng


> On 24 Jun 2019, at 06:08, david.j...@gmail.com wrote:
>
> On Saturday, 15 June 2019 01:48:55 UTC+10, k.groch...@gmail.com wrote:
>> Not to mention, using a 64-bit seed and using SplitMix64 is fundamentally flawed in case of xoroshiro64* and xoroshiro64**.

You can simply iterate Mix32 on a seed. You can't get two zeroes in a row. Let's keep it simple... it's not complicated.

Ciao,

seba


--
Il tuo 5 x mille progetti
Sostieni la ricerca, investi sul futuro dei giovani
Universita` degli Studi di Milano - codice fiscale 80012650158

Sebastiano Vigna

unread,
Jun 24, 2019, 3:05:18 AM6/24/19
to prng

> On 24 Jun 2019, at 09:01, Sebastiano Vigna <sebastia...@unimi.it> wrote:
>
> You can simply iterate Mix32 on a seed. You can't get two zeroes in a row. Let's keep it simple... it's not complicated.

Of course, a nonzero seed. :)

k.grocho...@gmail.com

unread,
Jun 24, 2019, 3:34:57 AM6/24/19
to prng
> >> Not to mention, using a 64-bit seed and using SplitMix64 is fundamentally flawed in case of xoroshiro64* and xoroshiro64**.
>
> You can simply iterate Mix32 on a seed. You can't get two zeroes in a row. Let's keep it simple... it's not complicated.
>
> Ciao,
>
> seba
>
>
> --
> Il tuo 5 x mille progetti
> Sostieni la ricerca, investi sul futuro dei giovani
> Universita` degli Studi di Milano - codice fiscale 80012650158

Am I missing something or is http://xoshiro.di.unimi.it/mix32.c not existing?

Sebastiano Vigna

unread,
Jun 24, 2019, 3:40:00 AM6/24/19
to prng


> On 24 Jun 2019, at 09:34, k.grocho...@gmail.com wrote:
>
>>>> Not to mention, using a 64-bit seed and using SplitMix64 is fundamentally flawed in case of xoroshiro64* and xoroshiro64**.
>>
>
> Am I missing something or is http://xoshiro.di.unimi.it/mix32.c not existing?

Mix32/64 is the finalizer of a family of fast mixing functions designed by Austin Appleby (MurmurHash3) and used in a variety of context, from PRNGs, hash functions, hash tables, etc.

If you want a SplitMix32, just use as additive constant the 32-bit fixed-point representation of the golden ratio (0x9E3779B9) and the MurmurHash3 32-bit finalizer (this is in Java):

public final static int murmurHash3(int x) {
x ^= x >>> 16;
x *= 0x85ebca6b;
x ^= x >>> 13;
x *= 0xc2b2ae35;
x ^= x >>> 16;
return x;
Reply all
Reply to author
Forward
0 new messages