stream_for_pcg32 Subroutine

private subroutine stream_for_pcg32(master_seed, stream_id, gen)

Build the PCG32 generator belonging to stream_id. The derived seed drives a local SplitMix64 which supplies both the LCG state and the stream selector.

Arguments

Type IntentOptional Attributes Name
integer(kind=int64), intent(in) :: master_seed
integer(kind=default_int), intent(in) :: stream_id
type(pcg32_t), intent(out) :: gen

Calls

proc~~stream_for_pcg32~~CallsGraph proc~stream_for_pcg32 stream_for_pcg32 proc~splitmix64_next splitmix64_t%splitmix64_next proc~stream_for_pcg32->proc~splitmix64_next proc~splitmix64_seed splitmix64_t%splitmix64_seed proc~stream_for_pcg32->proc~splitmix64_seed proc~stream_seed stream_seed proc~stream_for_pcg32->proc~stream_seed proc~mix64 mix64 proc~splitmix64_next->proc~mix64 proc~u64_add u64_add proc~splitmix64_next->proc~u64_add proc~stream_seed->proc~mix64 proc~stream_seed->proc~u64_add proc~u64_mul u64_mul proc~stream_seed->proc~u64_mul proc~mix64->proc~u64_mul proc~u64_shr u64_shr proc~mix64->proc~u64_shr

Called by

proc~~stream_for_pcg32~~CalledByGraph proc~stream_for_pcg32 stream_for_pcg32 interface~stream_for stream_for interface~stream_for->proc~stream_for_pcg32

Variables

Type Visibility Attributes Name Initial
integer(kind=int64), private :: initial_seq
integer(kind=int64), private :: initial_state
type(splitmix64_t), private :: seeder

Source Code

   subroutine stream_for_pcg32(master_seed, stream_id, gen)
      !! Build the PCG32 generator belonging to `stream_id`. The derived seed
      !! drives a local SplitMix64 which supplies both the LCG state and the
      !! stream selector.
      integer(int64), intent(in) :: master_seed
      integer(default_int), intent(in) :: stream_id
      type(pcg32_t), intent(out) :: gen

      type(splitmix64_t) :: seeder
      integer(int64) :: initial_state, initial_seq

      call seeder%seed(stream_seed(master_seed, stream_id))
      ! Two separate statements on purpose: Fortran does not specify the order in
      ! which actual arguments are evaluated, so two `seeder%next()` calls inside
      ! one call statement would not be reproducible across compilers.
      initial_state = seeder%next()
      initial_seq = seeder%next()
      call gen%seed(initial_state, initial_seq)
   end subroutine stream_for_pcg32