PSCF v1.2
|
Random number generator on GPU. More...
#include <CudaRandom.h>
Public Member Functions | |
CudaRandom () | |
Constructor. | |
virtual | ~CudaRandom () |
Destructor. | |
void | setSeed (unsigned long long seed) |
Set value of random seed (private member variable seed_). | |
void | uniform (DeviceArray< float > &data) |
Populate array on device with random floats in (0, 1], uniform dist. | |
void | uniform (DeviceArray< double > &data) |
Populate array on device with random doubles in (0, 1], uniform dist. | |
void | normal (DeviceArray< float > &data, float stddev, float mean=0.0) |
Populate array on device with normal-distributed random floats. | |
void | normal (DeviceArray< double > &data, double stddev, double mean=0.0) |
Populate array on device with normal-distributed random doubles. | |
long | seed () |
Returns value of random seed (private member variable seed_). | |
Random number generator on GPU.
The generator may be seeded either by reading a seed from file, using the readParam() method, or by using setSeed() to set or reset it explicitly. In either case, inputting a positive integer causes that value to be used as a seed, but inputting a value of 0 causes the use of a seed that is generated from the system clock.
Definition at line 29 of file CudaRandom.h.
Pscf::CudaRandom::CudaRandom | ( | ) |
Constructor.
Definition at line 13 of file CudaRandom.cu.
|
virtual |
Destructor.
Definition at line 27 of file CudaRandom.cu.
void Pscf::CudaRandom::setSeed | ( | unsigned long long | seed | ) |
void Pscf::CudaRandom::uniform | ( | DeviceArray< float > & | data | ) |
Populate array on device with random floats in (0, 1], uniform dist.
data | array to populate |
Definition at line 54 of file CudaRandom.cu.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), and UTIL_CHECK.
void Pscf::CudaRandom::uniform | ( | DeviceArray< double > & | data | ) |
Populate array on device with random doubles in (0, 1], uniform dist.
data | array to populate |
Definition at line 69 of file CudaRandom.cu.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), and UTIL_CHECK.
void Pscf::CudaRandom::normal | ( | DeviceArray< float > & | data, |
float | stddev, | ||
float | mean = 0.0 ) |
Populate array on device with normal-distributed random floats.
Note: the input array must have an even number of elements. This is a requirement imposed by cuRAND, the random number generator software used by CudaRandom.
data | array to populate |
stddev | standard deviation (input) |
mean | mean value (input, default = 0.0) |
Definition at line 84 of file CudaRandom.cu.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), UTIL_CHECK, and UTIL_THROW.
void Pscf::CudaRandom::normal | ( | DeviceArray< double > & | data, |
double | stddev, | ||
double | mean = 0.0 ) |
Populate array on device with normal-distributed random doubles.
Note: the input array must have an even number of elements. This is a requirement imposed by cuRAND, the random number generator software used by CudaRandom.
data | array to populate |
stddev | standard deviation (input) |
mean | mean value (input, default = 0.0) |
Definition at line 104 of file CudaRandom.cu.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), UTIL_CHECK, and UTIL_THROW.
|
inline |
Returns value of random seed (private member variable seed_).
Definition at line 116 of file CudaRandom.h.
Referenced by setSeed().