alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::rand::engine::internal::PhiloxSingle< TParams > Class Template Reference

Philox engine generating a single number. More...

#include <PhiloxSingle.hpp>

Inheritance diagram for alpaka::rand::engine::internal::PhiloxSingle< TParams >:

Public Types

using Base = PhiloxBaseCommon<TParams, PhiloxSingle<TParams>>
using Counter = typename Base::Counter
 Counter type.
using Key = typename Base::Key
 Key type.
using State = PhiloxState<Counter, Key, PhiloxSingle<TParams>>
Public Types inherited from alpaka::rand::engine::internal::PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
using Counter
using Key
using ResultContainer
 Distribution container type.
using State
 State type.
Public Types inherited from alpaka::rand::engine::internal::PhiloxStateless< T_Params >
using Counter = alpaka::Vec<std::uint32_t, T_Params::counterSize>
using Key = alpaka::Vec<std::uint32_t, T_Params::counterSize / 2>

Public Member Functions

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 operator() ()
 Get the next random number.
Public Member Functions inherited from alpaka::rand::engine::internal::PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
constexpr PhiloxBaseCommon (State &&state)

Protected Member Functions

constexpr void advanceState ()
 Advance internal counter to the next value.
constexpr auto nextNumber ()
 Get the next random number and advance internal state.
constexpr void skip (uint64_t offset)
 Skips the next offset numbers.
Protected Member Functions inherited from alpaka::rand::engine::internal::PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
constexpr void skip4 (uint64_t offset)
 Advance the internal state counter by offset N-vectors (N = counter size).
constexpr void skipSubsequence (uint64_t subsequence)
 Advance the counter by the length of subsequence.

Additional Inherited Members

Static Public Member Functions inherited from alpaka::rand::engine::internal::PhiloxStateless< T_Params >
static constexpr auto generate (Counter const &counter, Key const &key) -> Counter
 Generates a random number (TCounterSize x32-bit).
Public Attributes inherited from alpaka::rand::engine::internal::PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
State state
 Internal engine state.
Static Protected Member Functions inherited from alpaka::rand::engine::internal::PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
static constexpr void advanceCounter (alpaka::Vec< T, N > &counter)
 Advance the counter to the next state.
Static Protected Member Functions inherited from alpaka::rand::engine::internal::PhiloxStateless< T_Params >
static constexpr auto bumpKey (Key const &key)
 Bump the key by the Weyl sequence step parameter.
static constexpr auto nRounds (Counter const &counter_in, Key const &key_in) -> Counter
 Performs N rounds of the Philox shuffle.
static constexpr auto singleRound (Counter const &counter, Key const &key)
 Single round of the Philox shuffle.

Detailed Description

template<typename TParams>
class alpaka::rand::engine::internal::PhiloxSingle< TParams >

Philox engine generating a single number.

This engine's operator() will return a single number. Since the result is the same size as the counter, and so it contains more than one number, it has to be stored between individual invocations of operator(). Additionally a pointer has to be stored indicating which part of the result array is to be returned next.

Template Parameters
TParamsBasic parameters for the Philox algorithm

Definition at line 26 of file PhiloxSingle.hpp.

Member Typedef Documentation

◆ Base

template<typename TParams>
using alpaka::rand::engine::internal::PhiloxSingle< TParams >::Base = PhiloxBaseCommon<TParams, PhiloxSingle<TParams>>

Definition at line 29 of file PhiloxSingle.hpp.

◆ Counter

template<typename TParams>
using alpaka::rand::engine::internal::PhiloxSingle< TParams >::Counter = typename Base::Counter

Counter type.

Definition at line 32 of file PhiloxSingle.hpp.

◆ Key

template<typename TParams>
using alpaka::rand::engine::internal::PhiloxSingle< TParams >::Key = typename Base::Key

Key type.

Definition at line 34 of file PhiloxSingle.hpp.

◆ State

template<typename TParams>
using alpaka::rand::engine::internal::PhiloxSingle< TParams >::State = PhiloxState<Counter, Key, PhiloxSingle<TParams>>

Definition at line 35 of file PhiloxSingle.hpp.

Constructor & Destructor Documentation

◆ PhiloxSingle()

template<typename TParams>
alpaka::rand::engine::internal::PhiloxSingle< TParams >::PhiloxSingle ( uint64_t seed = 0,
uint64_t subsequence = 0,
uint64_t offset = 0 )
inlineconstexpr

Construct a new Philox engine with single-value output.

Parameters
seedSet the Philox generator key
subsequenceSelect a subsequence of size 2^64
offsetSkip offset numbers from the start of the subsequence

Definition at line 108 of file PhiloxSingle.hpp.

Member Function Documentation

◆ advanceState()

template<typename TParams>
void alpaka::rand::engine::internal::PhiloxSingle< TParams >::advanceState ( )
inlineconstexprprotected

Advance internal counter to the next value.

Advances the full internal counter array, resets the position pointer and stores the intermediate result to be recalled when the user requests a number.

Definition at line 44 of file PhiloxSingle.hpp.

◆ nextNumber()

template<typename TParams>
auto alpaka::rand::engine::internal::PhiloxSingle< TParams >::nextNumber ( )
inlineconstexprprotected

Get the next random number and advance internal state.

The intermediate result stores N = TParams::counterSize numbers. Check if we've already given out all of them. If so, generate a new intermediate result (this also resets the pointer to the position of the actual number). Finally, we return the actual number.

Returns
The next random number

Definition at line 59 of file PhiloxSingle.hpp.

◆ operator()()

template<typename TParams>
auto alpaka::rand::engine::internal::PhiloxSingle< TParams >::operator() ( )
inlineconstexpr

Get the next random number.

Returns
The next random number

Definition at line 120 of file PhiloxSingle.hpp.

◆ skip()

template<typename TParams>
void alpaka::rand::engine::internal::PhiloxSingle< TParams >::skip ( uint64_t offset)
inlineconstexprprotected

Skips the next offset numbers.

Definition at line 84 of file PhiloxSingle.hpp.


The documentation for this class was generated from the following file: