Deterministic seed for stream_id under master_seed.
mix64 is applied to the master seed, the stream id is spread over the
whole word by multiplying stream_id + 1 by the golden-ratio constant,
the two are combined with ieor, and the result is mixed once more.
Adding one to the id keeps stream 0 from collapsing the multiplication
to zero. Only bit-model and modular arithmetic is used, so the mapping
is identical on every compiler.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=int64), | intent(in) | :: | master_seed | |||
| integer(kind=default_int), | intent(in) | :: | stream_id |
pure function stream_seed(master_seed, stream_id) result(s) !! Deterministic seed for `stream_id` under `master_seed`. !! !! `mix64` is applied to the master seed, the stream id is spread over the !! whole word by multiplying `stream_id + 1` by the golden-ratio constant, !! the two are combined with `ieor`, and the result is mixed once more. !! Adding one to the id keeps stream 0 from collapsing the multiplication !! to zero. Only bit-model and modular arithmetic is used, so the mapping !! is identical on every compiler. integer(int64), intent(in) :: master_seed integer(default_int), intent(in) :: stream_id integer(int64) :: s s = mix64(ieor(mix64(master_seed), & u64_mul(u64_add(int(stream_id, int64), 1_int64), GOLDEN_GAMMA))) end function stream_seed