PSCF v1.4.0
Pscf::CudaVecRandom Class Reference

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_).

Detailed Description

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.

Constructor & Destructor Documentation

◆ CudaVecRandom()

Pscf::CudaVecRandom::CudaVecRandom ( )

Constructor.

Definition at line 77 of file CudaVecRandom.cu.

◆ ~CudaVecRandom()

Pscf::CudaVecRandom::~CudaVecRandom ( )
virtual

Destructor.

Definition at line 91 of file CudaVecRandom.cu.

Member Function Documentation

◆ setSeed()

void Pscf::CudaVecRandom::setSeed ( unsigned long long seed)

Set value of random seed (private member variable seed_).

Parameters
seedvalue of random number generator seed.

Definition at line 99 of file CudaVecRandom.cu.

References seed().

Referenced by normal(), normal(), uniform(), and uniform().

◆ uniform() [1/4]

void Pscf::CudaVecRandom::uniform ( DeviceArray< float > & data)

Populate array with uniform random floats in (0, 1].

Parameters
dataarray to populate

Definition at line 118 of file CudaVecRandom.cu.

References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), and UTIL_CHECK.

Referenced by uniform(), and uniform().

◆ uniform() [2/4]

void Pscf::CudaVecRandom::uniform ( DeviceArray< double > & data)

Populate array with uniform random doubles in (0, 1].

Parameters
dataarray to populate

Definition at line 134 of file CudaVecRandom.cu.

References Pscf::DeviceArray< Data >::capacity(), Pscf::DeviceArray< Data >::cArray(), setSeed(), and UTIL_CHECK.

◆ uniform() [3/4]

void Pscf::CudaVecRandom::uniform ( DeviceArray< float > & data,
float min,
float max )

Populate array with uniform random floats in (min, max].

Parameters
dataarray to populate
minminimum of range
maxmaximum of range

Definition at line 150 of file CudaVecRandom.cu.

References uniform(), and UTIL_CHECK.

◆ uniform() [4/4]

void Pscf::CudaVecRandom::uniform ( DeviceArray< double > & data,
double min,
double max )

Populate array with uniform random doubles in (min, max].

Parameters
dataarray to populate
minminimum of range
maxmaximum of range

Definition at line 161 of file CudaVecRandom.cu.

References uniform(), and UTIL_CHECK.

◆ normal() [1/2]

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.

Parameters
dataarray to populate
stddevstandard deviation (input)
meanmean 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.

◆ normal() [2/2]

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.

Parameters
dataarray to populate
stddevstandard deviation (input)
meanmean 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.

◆ seed()

long Pscf::CudaVecRandom::seed ( )
inline

Returns value of random seed (private member variable seed_).

Returns
value of random number generator seed.

Definition at line 135 of file CudaVecRandom.h.

Referenced by setSeed().


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