Class RandomManager

Class Documentation

class flamegpu::RandomManager

Singleton manager for initialising simulation wide random with a common seed This is an internal class, that should not be accessed directly by modellers Manages the shared array of curand state use by agent functions Manages the random engine/s used by host functions

See

AgentRandom For random number generation during agent functions on the device

See

HostRandom For random number generation during host functions

Public Types

typedef unsigned int size_type

Inherit size_type from include-public partner class

Public Functions

RandomManager()

Creates the random manager and calls reseed() with the return value from seedFromTime()

~RandomManager()
uint64_t seedFromTime()

Utility for generating a psuesdo-random seed to pass to init

Member fns

void reseed(const uint64_t &seed)

Reseeds all owned random generators

Note

Can be called multiple times to reseed, doing so releases existing memory allocations

curandState *resize(const size_type &_length)

Resizes random array according to the rules: while(length<_length) length*=growthModifier if(shrinkModifier<1.0) while(length*shrinkModifier>_length) length*=shrinkModifier

void setGrowthModifier(float)

Accessors

float getGrowthModifier()
void setShrinkModifier(float)
float getShrinkModifier()
template<typename T, typename dist>
T getDistribution(dist &distribution)

Generates a random number with the provided distribution

Note

Not believed to be thread-safe!

Parameters

distribution – A distribution object defined by <random>

Template Parameters
  • dist – random distribution type to be used for generation (this should be implicitly detected)

  • T – return type

size_type size()

Returns length of curand state array currently allocated

uint64_t seed()
curandState *cudaRandomState()
RandomManager(RandomManager const&) = delete
void operator=(RandomManager const&) = delete