Template Class xorwow_engine

Class Documentation

template<unsigned long long DefaultSeed = HIPRAND_XORWOW_DEFAULT_SEED>
class xorwow_engine

Pseudorandom number engine based XORWOW algorithm.

xorwow_engine is a xorshift pseudorandom number engine based on XORWOW algorithm, which was presented by George Marsaglia in “Xorshift RNGs” paper published in Journal of Statistical Software. It produces random numbers of type unsigned int on the interval [0; 2^32 - 1].

Public Types

typedef unsigned int result_type

Type of values generated by the random number engine.

typedef unsigned long long offset_type

Pseudo-random number engine offset type. Offset represents a number of the random number engine’s states that should be skipped before first value is generated.

See also: offset()

typedef unsigned long long seed_type

Pseudo-random number engine seed type definition.

See also: seed()

Public Functions

inline xorwow_engine(seed_type seed_value = DefaultSeed, offset_type offset_value = 0)

Constructs the pseudo-random number engine.

See also: hiprandCreateGenerator()

Parameters:
  • seed_value – - seed value to use in the initialization of the internal state, see also seed()

  • offset_value – - number of internal states that should be skipped, see also offset()

inline xorwow_engine(hiprandGenerator_t &generator)

Constructs the pseudo-random number engine.

The pseudo-random number engine will be created using generator. The constructed engine take ownership over generator, and sets passed reference to NULL. The lifetime of generator is now bound to the lifetime of the engine.

Parameters:

generator – - hipRAND generator

inline ~xorwow_engine()

Destructs the engine.

See also: hiprandDestroyGenerator()

inline void stream(hipStream_t value)

Sets the random number engine’s hipStream for kernel launches.

Parameters:

value – - new hipStream to use

inline void offset(offset_type value)

Sets the offset of a random number engine.

Offset represents a number of the random number engine’s states that should be skipped before first value is generated.

  • This operation resets the engine’s internal state.

  • This operation does not change the engine’s seed or the number of dimensions.

See also: hiprandSetGeneratorOffset()

Parameters:

value – - New absolute offset

inline void seed(seed_type value)

Sets the seed of the pseudo-random number engine.

  • This operation resets the engine’s internal state.

  • This operation does not change the engine’s offset.

See also: hiprandSetPseudoRandomGeneratorSeed()

Parameters:

value – - New seed value

template<class Generator>
inline void operator()(result_type *output, size_t size)

Fills output with uniformly distributed random integer values.

Generates size random integer values uniformly distributed on the interval [0, 2^32 - 1], and stores them into the device memory referenced by output pointer.

The device memory pointed by output must have been previously allocated and be large enough to store at least size values of IntType type.

See also: hiprandGenerate()

Parameters:
  • output – - Pointer to device memory to store results

  • size – - Number of values to generate

inline result_type min() const

Returns the smallest possible value that can be generated by the engine.

inline result_type max() const

Returns the largest possible value that can be generated by the engine.

Public Static Functions

static inline hiprandRngType type()

Returns type of the hipRAND pseudo-random number generator associated with the engine.

Public Static Attributes

static seed_type default_seed = DefaultSeed

The default seed equal to DefaultSeed.