25 template<
typename TParams>
48 this->
state.position = 0;
62 auto result = this->
state.result[0];
63 ++this->
state.position;
64 if(this->
state.position == TParams::counterSize)
84 constexpr void skip(uint64_t offset)
86 static_assert(TParams::counterSize == 4,
"Only counterSize is supported.");
87 this->
state.position =
static_cast<decltype(this-
>state.position)>(this->
state.position + (offset & 3));
88 offset += this->
state.position < 4 ? 0 : 4;
89 this->
state.position -= this->
state.position < 4 ? 0 : 4u;
90 for(
auto numShifts = this->
state.position; numShifts > 0; --numShifts)
98 this->
skip4(offset / 4);
108 constexpr PhiloxSingle(uint64_t seed = 0, uint64_t subsequence = 0, uint64_t offset = 0)
109 :
Base(
State{{0, 0, 0, 0}, {
low32Bits(seed),
high32Bits(seed)}, {0, 0, 0, 0}, 0u})
111 this->skipSubsequence(subsequence);
typename PhiloxStateless< T_Params >::Counter Counter
typename PhiloxStateless< T_Params >::Key Key
State state
Internal engine state.
constexpr void skip4(uint64_t offset)
constexpr PhiloxBaseCommon(State &&state)
static constexpr void advanceCounter(alpaka::Vec< T, N > &counter)
constexpr void skip(uint64_t offset)
Skips the next offset numbers.
constexpr PhiloxSingle(uint64_t seed=0, uint64_t subsequence=0, uint64_t offset=0)
Construct a new Philox engine with single-value output.
constexpr auto nextNumber()
Get the next random number and advance internal state.
constexpr void advanceState()
Advance internal counter to the next value.
constexpr auto operator()()
Get the next random number.
PhiloxBaseCommon< EngineParams, PhiloxSingle< EngineParams > > Base
PhiloxState< Counter, Key, PhiloxSingle< EngineParams > > State
typename Base::Counter Counter
static constexpr auto nRounds(Counter const &counter_in, Key const &key_in) -> Counter
Performs N rounds of the Philox shuffle.
constexpr auto low32Bits(std::uint64_t const x) -> std::uint32_t
Get low 32 bits of a 64-bit number.
constexpr auto high32Bits(std::uint64_t const x) -> std::uint32_t
Get high 32 bits of a 64-bit number.