General purpose utilities. More...
Classes | |
| class | amrex::ParmParse |
| Parse Parameters From Command Line and Input Files. More... | |
| class | amrex::IParser |
| class | amrex::Parser |
Functions | |
| Real | amrex::Random () |
| Generate a psuedo-random double from uniform distribution. | |
| __host__ __device__ Real | amrex::Random (RandomEngine const &random_engine) |
| Real | amrex::RandomNormal (Real mean, Real stddev) |
| Generate a psuedo-random double from a normal distribution. | |
| __host__ __device__ Real | amrex::RandomNormal (Real mean, Real stddev, RandomEngine const &random_engine) |
| unsigned int | amrex::RandomPoisson (Real lambda) |
| Generate a psuedo-random integer from a Poisson distribution. | |
| __host__ __device__ unsigned int | amrex::RandomPoisson (Real lambda, RandomEngine const &random_engine) |
| Real | amrex::RandomGamma (Real alpha, Real beta) |
| Generate a psuedo-random floating point number from the Gamma distribution. | |
| __host__ __device__ Real | amrex::RandomGamma (Real alpha, Real beta, RandomEngine const &random_engine) |
| unsigned int | amrex::Random_int (unsigned int n) |
| Generates one pseudorandom unsigned integer which is uniformly distributed on [0,n-1]-interval for each call. | |
| __host__ __device__ unsigned int | amrex::Random_int (unsigned int n, RandomEngine const &random_engine) |
| ULong | amrex::Random_long (ULong n) |
| Generates one pseudorandom unsigned long which is uniformly distributed on [0,n-1]-interval for each call. | |
| void | amrex::FillRandom (Real *p, Long N) |
| void | amrex::FillRandomNormal (Real *p, Long N, Real mean, Real stddev) |
| void | amrex::InitRandom (ULong cpu_seed, int nprocs=ParallelDescriptor::NProcs(), ULong gpu_seed=detail::DefaultGpuSeed()) |
| Set the seed of the random number generator. | |
| void | amrex::ResetRandomSeed (ULong cpu_seed, ULong gpu_seed=detail::DefaultGpuSeed()) |
| void | amrex::SaveRandomState (std::ostream &os) |
| Save and restore random state. | |
| void | amrex::RestoreRandomState (std::istream &is, int nthreads_old, int nstep_old) |
| void | amrex::UniqueRandomSubset (Vector< int > &uSet, int setSize, int poolSize, bool printSet=false) |
| Create a unique subset of random numbers from a pool of integers in the range [0, poolSize - 1] the set will be in the order they are found setSize must be <= poolSize uSet will be resized to setSize if you want all processors to have the same set, call this on one processor and broadcast the array. | |
General purpose utilities.
This topic covers general purpose utilities used throughout AMReX and AMReX applications.
Central capabilities include:
Fill random numbers from uniform distribution. The range is [0,1) for CPU and SYCl, and (0,1] for CUADA and HIP.
Fill random numbers from normal distribution
| void amrex::InitRandom | ( | ULong | cpu_seed, |
| int | nprocs = ParallelDescriptor::NProcs(), |
||
| ULong | gpu_seed = detail::DefaultGpuSeed() |
||
| ) |
Set the seed of the random number generator.
There is also an entry point for Fortran callable as:
INTEGER seed call blutilinitrand(seed)
or
INTEGER seed call blinitrand(seed)
| Real amrex::Random | ( | ) |
Generate a psuedo-random double from uniform distribution.
Generates one pseudorandom real number (double) from a uniform distribution between 0.0 and 1.0 (0.0 included, 1.0 excluded)
|
inline |
| unsigned int amrex::Random_int | ( | unsigned int | n | ) |
Generates one pseudorandom unsigned integer which is uniformly distributed on [0,n-1]-interval for each call.
The CPU version of this function uses C++11's mt19937. The GPU version uses CURAND's XORWOW generator.
|
inline |
Generates one pseudorandom unsigned long which is uniformly distributed on [0,n-1]-interval for each call.
The CPU version of this function uses C++11's mt19937. There is no GPU version.
Generate a psuedo-random floating point number from the Gamma distribution.
Generates one real number (single or double) extracted from a Gamma distribution, given the Real parameters alpha and beta. alpha and beta must both be > 0. The CPU version of this function relies on the Standard Template Library The GPU version of this function relies is implemented in terms of Random and RandomNormal.
|
inline |
Generate a psuedo-random double from a normal distribution.
Generates one pseudorandom real number (double) from a normal distribution with mean 'mean' and standard deviation 'stddev'.
|
inline |
| unsigned int amrex::RandomPoisson | ( | Real | lambda | ) |
Generate a psuedo-random integer from a Poisson distribution.
Generates one pseudorandom positive integer number (double) extracted from a Poisson distribution, given the Real parameter lambda. The CPU version of this function relies on the standard Template Library The GPU version of this function relies on the cuRAND library
|
inline |
| void amrex::RestoreRandomState | ( | std::istream & | is, |
| int | nthreads_old, | ||
| int | nstep_old | ||
| ) |
| void amrex::SaveRandomState | ( | std::ostream & | os | ) |
Save and restore random state.
| void amrex::UniqueRandomSubset | ( | Vector< int > & | uSet, |
| int | setSize, | ||
| int | poolSize, | ||
| bool | printSet | ||
| ) |
Create a unique subset of random numbers from a pool of integers in the range [0, poolSize - 1] the set will be in the order they are found setSize must be <= poolSize uSet will be resized to setSize if you want all processors to have the same set, call this on one processor and broadcast the array.