alpaka
Abstraction Library for Parallel Kernel Acceleration
alpaka::rand::engine::PhiloxSingle< TParams > Class Template Reference

#include <PhiloxSingle.hpp>

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

Public Types

using Base = PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
 
using Counter = typename Base::Counter
 Counter type. More...
 
using Key = typename Base::Key
 Key type. More...
 
using State = PhiloxStateSingle< Counter, Key >
 State type. More...
 
- Public Types inherited from alpaka::rand::engine::PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
using Counter = typename PhiloxStateless< TParams >::Counter
 
using Key = typename PhiloxStateless< TParams >::Key
 
using ResultContainer = typename alpaka::Vec< alpaka::DimInt< TParams::counterSize >, TDistributionResultScalar >
 Distribution container type. More...
 
- Public Types inherited from alpaka::rand::engine::PhiloxStateless< TParams >
using Constants = PhiloxConstants< TParams >
 
using Counter = alpaka::Vec< alpaka::DimInt< TParams::counterSize >, std::uint32_t >
 
using Key = alpaka::Vec< alpaka::DimInt< TParams::counterSize/2 >, std::uint32_t >
 

Public Member Functions

ALPAKA_FN_HOST_ACC PhiloxSingle (uint64_t seed=0, uint64_t subsequence=0, uint64_t offset=0)
 
ALPAKA_FN_HOST_ACC auto operator() ()
 

Public Attributes

State state
 Internal engine state. More...
 

Protected Member Functions

ALPAKA_FN_HOST_ACC void advanceState ()
 
ALPAKA_FN_HOST_ACC auto nextNumber ()
 
ALPAKA_FN_HOST_ACC void skip (uint64_t offset)
 Skips the next offset numbers. More...
 
- Protected Member Functions inherited from alpaka::rand::engine::PhiloxBaseCommon< TParams, PhiloxSingle< TParams > >
ALPAKA_FN_HOST_ACC void advanceCounter (Counter &counter)
 
ALPAKA_FN_HOST_ACC void skip4 (uint64_t offset)
 
ALPAKA_FN_HOST_ACC void skipSubsequence (uint64_t subsequence)
 

Additional Inherited Members

- Static Public Member Functions inherited from alpaka::rand::engine::PhiloxStateless< TParams >
static ALPAKA_FN_HOST_ACC auto generate (Counter const &counter, Key const &key) -> Counter
 
- Static Public Member Functions inherited from alpaka::rand::engine::PhiloxConstants< TParams >
static constexpr std::uint32_t MULTIPLITER_4x32_0 ()
 First Philox S-box multiplier. More...
 
static constexpr std::uint32_t MULTIPLITER_4x32_1 ()
 Second Philox S-box multiplier. More...
 
static constexpr std::uint32_t WEYL_32_0 ()
 1st Weyl sequence parameter, 32 bits More...
 
static constexpr std::uint32_t WEYL_32_1 ()
 2nd Weyl sequence parameter, 32 bits More...
 
static constexpr std::uint64_t WEYL_64_0 ()
 First Weyl sequence parameter: the golden ratio. More...
 
static constexpr std::uint64_t WEYL_64_1 ()
 Second Weyl sequence parameter: $ \sqrt{3}-1 $. More...
 
- Static Protected Member Functions inherited from alpaka::rand::engine::PhiloxStateless< TParams >
static ALPAKA_FN_HOST_ACC auto bumpKey (Key const &key)
 
static ALPAKA_FN_HOST_ACC auto nRounds (Counter const &counter_in, Key const &key_in) -> Counter
 
static ALPAKA_FN_HOST_ACC auto singleRound (Counter const &counter, Key const &key)
 

Detailed Description

template<typename TParams>
class alpaka::rand::engine::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 46 of file PhiloxSingle.hpp.

Member Typedef Documentation

◆ Base

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

Definition at line 49 of file PhiloxSingle.hpp.

◆ Counter

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

Counter type.

Definition at line 52 of file PhiloxSingle.hpp.

◆ Key

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

Key type.

Definition at line 54 of file PhiloxSingle.hpp.

◆ State

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

State type.

Definition at line 56 of file PhiloxSingle.hpp.

Constructor & Destructor Documentation

◆ PhiloxSingle()

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

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 form the start of the subsequence

Definition at line 131 of file PhiloxSingle.hpp.

Member Function Documentation

◆ advanceState()

template<typename TParams >
ALPAKA_FN_HOST_ACC void alpaka::rand::engine::PhiloxSingle< TParams >::advanceState ( )
inlineprotected

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 67 of file PhiloxSingle.hpp.

◆ nextNumber()

template<typename TParams >
ALPAKA_FN_HOST_ACC auto alpaka::rand::engine::PhiloxSingle< TParams >::nextNumber ( )
inlineprotected

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 82 of file PhiloxSingle.hpp.

◆ operator()()

template<typename TParams >
ALPAKA_FN_HOST_ACC auto alpaka::rand::engine::PhiloxSingle< TParams >::operator() ( )
inline

Get the next random number

Returns
The next random number

Definition at line 143 of file PhiloxSingle.hpp.

◆ skip()

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

Skips the next offset numbers.

Definition at line 107 of file PhiloxSingle.hpp.

Member Data Documentation

◆ state

template<typename TParams >
State alpaka::rand::engine::PhiloxSingle< TParams >::state

Internal engine state.

Definition at line 59 of file PhiloxSingle.hpp.


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