Class RandomManager

Class Documentation

class 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 also

AgentRandom For random number generation during agent functions on the device

See also

HostRandom For random number generation during host functions

Public Functions


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

uint64_t seedFromTime()

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

Member fns

void reseed(uint64_t seed)

Reseeds all owned random generators


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

detail::curandState *resize(size_type _length, cudaStream_t stream)

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)


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

Generates a random number with the provided distribution


Not believed to be thread-safe!


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()
detail::curandState *cudaRandomState()
RandomManager(RandomManager const&) = delete
void operator=(RandomManager const&) = delete