Open Qmin  0.8.0
GPU-accelerated Q-tensor-based liquid crystal simulations
Public Member Functions | Public Attributes | List of all members
noiseSource Class Reference

A class that gives access to a RNG on the cpu and gpu. More...

#include <noiseSource.h>

Collaboration diagram for noiseSource:
Collaboration graph
[legend]

Public Member Functions

 noiseSource (bool rep=false)
 base constructor More...
 
int getInt (int minimum, int maximum)
 Get a reproducible integer. More...
 
scalar getRealUniform (scalar minimum=0., scalar maximum=1.)
 Get a real from uniform distribution. More...
 
scalar getRealNormal (scalar mean=0., scalar std=1.)
 Get a real from normal distribution. More...
 
void initialize (int _N)
 Set the array size of the cuda rngs. More...
 
void setReproducible (bool _rep)
 set reproducibility More...
 
void setReproducibleSeed (int _seed)
 set the seed on a reproducible RNG run More...
 
void initializeGPURNGs (int globalSeed=1337, int tempSeed=0)
 allow for whatever GPU RNG initialization is needed More...
 

Public Attributes

bool Reproducible
 should the dynamics be reproducible? More...
 
int N
 number of entries for the cuda RNG More...
 
int RNGSeed
 The seed used by the random number generator, when non-reproducible dynamics have been set. More...
 
random_device rd
 an initializer for non-reproducible random number generation on the cpu More...
 
mt19937 gen
 A reproducible Mersenne Twister. More...
 
mt19937 genrd
 A non-reproducible Mersenne Twister. More...
 
bool initializeGPURNG
 A flag to determine whether the CUDA RNGs should be initialized or not (so that the program will run on systems with no GPU by setting this to false. More...
 
GPUArray< curandState > RNGs
 An array random-number-generators for use on the GPU branch of the code. More...
 

Detailed Description

A class that gives access to a RNG on the cpu and gpu.

Provides features to some psuedo-rng functions. On the CPU side, one can call for a random integer (in a specified range), a random real with a uniform distribution, or a random real from a normal distribution. On the GPU side, provides access to a GPUArray of curandState objects, and functionality to initialize them.

Constructor & Destructor Documentation

◆ noiseSource()

noiseSource::noiseSource ( bool  rep = false)
inline

base constructor

References gen, genrd, rd, and Reproducible.

Member Function Documentation

◆ getInt()

int noiseSource::getInt ( int  minimum,
int  maximum 
)

Get a reproducible integer.

References gen, genrd, and Reproducible.

Referenced by poissonDiskSampling::poissonDiskSampling().

◆ getRealUniform()

scalar noiseSource::getRealUniform ( scalar  minimum = 0.,
scalar  maximum = 1. 
)

◆ getRealNormal()

scalar noiseSource::getRealNormal ( scalar  mean = 0.,
scalar  std = 1. 
)

Get a real from normal distribution.

References gen, genrd, Reproducible, and scalar.

Referenced by cubicLattice::setSpinsRandomly(), and simpleModel::setVelocitiesMaxwellBoltzmann().

◆ initialize()

void noiseSource::initialize ( int  _N)
inline

Set the array size of the cuda rngs.

References N, GPUArray< T >::resize(), and RNGs.

Referenced by qTensorLatticeModel::setNematicQTensorRandomly(), and cubicLattice::setSpinsRandomly().

◆ setReproducible()

void noiseSource::setReproducible ( bool  _rep)
inline

set reproducibility

References Reproducible.

◆ setReproducibleSeed()

void noiseSource::setReproducibleSeed ( int  _seed)

set the seed on a reproducible RNG run

References gen, genrd, and RNGSeed.

◆ initializeGPURNGs()

void noiseSource::initializeGPURNGs ( int  globalSeed = 1337,
int  tempSeed = 0 
)

allow for whatever GPU RNG initialization is needed

Parameters
globalSeedthe global seed to use
tempSeeda value of the offset that should be sent to the cuda RNG... This is one part of what would be required to support reproducibly being able to load a state from a databse and continue the dynamics in the same way every time. This is not currently supported.

References ArrayHandle< T >::data, access_location::device, GPUArray< T >::getNumElements(), gpu_initialize_RNG_array(), N, access_mode::overwrite, Reproducible, GPUArray< T >::resize(), RNGs, and RNGSeed.

Referenced by qTensorLatticeModel::setNematicQTensorRandomly(), and cubicLattice::setSpinsRandomly().

Member Data Documentation

◆ Reproducible

bool noiseSource::Reproducible

should the dynamics be reproducible?

Referenced by getInt(), getRealNormal(), getRealUniform(), initializeGPURNGs(), noiseSource(), and setReproducible().

◆ N

int noiseSource::N

number of entries for the cuda RNG

Referenced by initialize(), and initializeGPURNGs().

◆ RNGSeed

int noiseSource::RNGSeed

The seed used by the random number generator, when non-reproducible dynamics have been set.

Referenced by initializeGPURNGs(), and setReproducibleSeed().

◆ rd

random_device noiseSource::rd

an initializer for non-reproducible random number generation on the cpu

Referenced by noiseSource().

◆ gen

mt19937 noiseSource::gen

A reproducible Mersenne Twister.

Referenced by getInt(), getRealNormal(), getRealUniform(), noiseSource(), and setReproducibleSeed().

◆ genrd

mt19937 noiseSource::genrd

A non-reproducible Mersenne Twister.

Referenced by getInt(), getRealNormal(), getRealUniform(), noiseSource(), and setReproducibleSeed().

◆ initializeGPURNG

bool noiseSource::initializeGPURNG

A flag to determine whether the CUDA RNGs should be initialized or not (so that the program will run on systems with no GPU by setting this to false.

◆ RNGs

GPUArray<curandState> noiseSource::RNGs

An array random-number-generators for use on the GPU branch of the code.

Referenced by initialize(), initializeGPURNGs(), qTensorLatticeModel::setNematicQTensorRandomly(), and cubicLattice::setSpinsRandomly().


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