|
PSCF v1.4.0
|
Random number generator on GPU. More...
#include <CudaVecRandom.h>
Public Member Functions | |
| CudaVecRandom () | |
| Constructor. | |
| virtual | ~CudaVecRandom () |
| Destructor. | |
| void | setSeed (unsigned long long seed) |
| Set value of random seed (private member variable seed_). | |
| void | uniform (DeviceArray< float > &data) |
| Populate array with uniform random floats in (0, 1]. | |
| void | uniform (DeviceArray< double > &data) |
| Populate array with uniform random doubles in (0, 1]. | |
| void | uniform (DeviceArray< float > &data, float min, float max) |
| Populate array with uniform random floats in (min, max]. | |
| void | uniform (DeviceArray< double > &data, double min, double max) |
| Populate array with uniform random doubles in (min, max]. | |
| 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 long in seed from a file, using the readParam() method, or by using setSeed() method to set the seed. In either case, inputing 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 28 of file CudaVecRandom.h.
| Pscf::CudaVecRandom::CudaVecRandom | ( | ) |
Constructor.
Definition at line 77 of file CudaVecRandom.cu.
|
virtual |
Destructor.
Definition at line 91 of file CudaVecRandom.cu.
| void Pscf::CudaVecRandom::setSeed | ( | unsigned long long | seed | ) |
| void Pscf::CudaVecRandom::uniform | ( | DeviceArray< float > & | data | ) |
Populate array with uniform random floats in (0, 1].
| data | array to populate |
Definition at line 118 of file CudaVecRandom.cu.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), and UTIL_CHECK.
| void Pscf::CudaVecRandom::uniform | ( | DeviceArray< double > & | data | ) |
Populate array with uniform random doubles in (0, 1].
| data | array to populate |
Definition at line 134 of file CudaVecRandom.cu.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), and UTIL_CHECK.
| void Pscf::CudaVecRandom::uniform | ( | DeviceArray< float > & | data, |
| float | min, | ||
| float | max ) |
Populate array with uniform random floats in (min, max].
| data | array to populate |
| min | minimum of range |
| max | maximum of range |
Definition at line 150 of file CudaVecRandom.cu.
References uniform(), and UTIL_CHECK.
| void Pscf::CudaVecRandom::uniform | ( | DeviceArray< double > & | data, |
| double | min, | ||
| double | max ) |
Populate array with uniform random doubles in (min, max].
| data | array to populate |
| min | minimum of range |
| max | maximum of range |
Definition at line 161 of file CudaVecRandom.cu.
References uniform(), and UTIL_CHECK.
| void Pscf::CudaVecRandom::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 library used by CudaVecRandom.
| data | array to populate |
| stddev | standard deviation (input) |
| mean | mean value (input, default = 0.0) |
Definition at line 172 of file CudaVecRandom.cu.
References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), UTIL_CHECK, and UTIL_THROW.
| void Pscf::CudaVecRandom::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 CudaVecRandom.
| data | array to populate |
| stddev | standard deviation (input) |
| mean | mean value (input, default = 0.0) |
Definition at line 193 of file CudaVecRandom.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 135 of file CudaVecRandom.h.
Referenced by setSeed().