|
| constexpr | Per_Thread_RNG (const std::uint64_t seed=0) noexcept |
| | Build a dispenser around seed.
|
| |
| constexpr std::uint64_t | master_seed () const noexcept |
| | Return the master seed.
|
| |
| template<std::size_t Rank> |
| Engine | for_cell (const std::size_t step, const Coord_Vec< Rank > &coord) const |
| | Build a fresh deterministic engine for cell (step, coord).
|
| |
| template<std::size_t Rank> |
| Engine | for_cell (const Cell_Context< Rank > &ctx) const |
| | Build a fresh deterministic engine from a Cell_Context.
|
| |
| Engine | for_thread_step (const std::size_t thread_id, const std::size_t step) const |
| | Build an engine for a (thread, step) sub-stream.
|
| |
template<typename Engine = std::mt19937_64>
class Aleph::CA::Per_Thread_RNG< Engine >
Master seed dispenser for stochastic CA rules.
Per_Thread_RNG does not own any RNG state: it is a pure factory that builds a fresh deterministic engine on demand from a master seed and either a per-cell context or a per-thread descriptor. This makes it cheap to copy, share between threads (no synchronisation required) and to compose with the Phase 5 parallel engine without serialisation hazards.
Typical usage inside a contextual rule:
struct My_Stochastic_Rule {
double p; std::uint64_t master;
template <typename State, std::size_t Rank>
auto eng =
rng.for_cell(ctx);
}
};
Master seed dispenser for stochastic CA rules.
std::span< const T > Neighbor_View
Read-only view over a contiguous range of neighbour values.
double uniform_unit(Engine &eng)
Map a 64-bit RNG output to a uniform value in [0, 1).
void next()
Advance all underlying iterators (bounds-checked).
Per-cell context handed to rules that need to know "where" and "when" they are firing.
- Template Parameters
-
| Engine | PRNG engine type. Defaults to std::mt19937_64 for its 64-bit output and good statistical quality. Any engine whose result_type is unsigned and at least 53 bits wide works. |
Definition at line 273 of file ca-rng.H.
template<typename Engine = std::mt19937_64>
template<std::size_t Rank>
Build a fresh deterministic engine for cell (step, coord).
The returned engine state depends only on (master_, step, coord), so two calls with the same arguments — possibly from different threads — produce identical streams.
- Template Parameters
-
| Rank | coordinate rank (deduced). |
- Parameters
-
| [in] | step | step index being evaluated. |
| [in] | coord | cell coordinate. |
- Returns
- engine seeded with
cell_seed(master_, step, coord).
- Exceptions
-
| Any | exception thrown by Engine's constructor. |
Definition at line 312 of file ca-rng.H.
References Aleph::CA::Per_Thread_RNG< Engine >::master_.
template<typename Engine = std::mt19937_64>
Build an engine for a (thread, step) sub-stream.
The result depends on (master_, thread_id, step) and is therefore not invariant under different thread counts. Use this overload only when you explicitly want a per-thread sub-stream rather than per-cell determinism.
- Parameters
-
| [in] | thread_id | stable identifier for the worker. |
| [in] | step | step index being evaluated. |
- Returns
- engine seeded with
thread_step_seed.
- Exceptions
-
| Any | exception thrown by Engine's constructor. |
Definition at line 342 of file ca-rng.H.
References Aleph::CA::Per_Thread_RNG< Engine >::master_, and Aleph::CA::thread_step_seed().