3 #include <AMReX_Config.H>
27 #if defined (__SYCL_DEVICE_ONLY__)
28 mkl::rng::device::uniform<Real> distr;
29 return mkl::rng::device::generate(distr, *random_engine.engine);
34 return 1.0f - hiprand_uniform(random_engine.
rand_state); ,
35 return 1.0f - curand_uniform(random_engine.
rand_state);
41 return 1.0 - hiprand_uniform_double(random_engine.
rand_state); ,
42 return 1.0 - curand_uniform_double(random_engine.
rand_state);
65 #if defined (__SYCL_DEVICE_ONLY__)
66 mkl::rng::device::gaussian<Real> distr(mean, stddev);
67 return mkl::rng::device::generate(distr, *random_engine.engine);
72 return stddev * hiprand_normal(random_engine.
rand_state) + mean; ,
73 return stddev * curand_normal(random_engine.
rand_state) + mean;
79 return stddev * hiprand_normal_double(random_engine.
rand_state) + mean; ,
80 return stddev * curand_normal_double(random_engine.
rand_state) + mean;
105 #if defined (__SYCL_DEVICE_ONLY__)
106 mkl::rng::device::poisson<unsigned int> distr(lambda);
107 return mkl::rng::device::generate(distr, *random_engine.engine);
111 return hiprand_poisson(random_engine.
rand_state, lambda); ,
112 return curand_poisson(random_engine.
rand_state, lambda);
150 Real d = alpha - 1.0_rt / 3.0_rt;
151 Real c = (1.0_rt / 3.0_rt) /
std::sqrt(d);
157 }
while (v <= 0.0_rt);
162 if (u < 1.0_rt - 0.0331_rt *
x *
x *
x *
x) {
193 #if defined(__SYCL_DEVICE_ONLY__)
194 mkl::rng::device::uniform<unsigned int> distr(0,n);
195 return mkl::rng::device::generate(distr, *random_engine.engine);
199 constexpr
unsigned int RAND_M = 4294967295;
203 }
while (rand > (RAND_M - RAND_M % n));
270 bool printSet =
false);
#define AMREX_ASSERT(EX)
Definition: AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_HIP_OR_CUDA(a, b)
Definition: AMReX_GpuControl.H:21
#define AMREX_IF_ON_DEVICE(CODE)
Definition: AMReX_GpuQualifiers.H:56
#define AMREX_IF_ON_HOST(CODE)
Definition: AMReX_GpuQualifiers.H:58
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
int MyProc() noexcept
return the rank number local to the current Parallel Context
Definition: AMReX_ParallelDescriptor.H:125
int NProcs() noexcept
return the number of MPI ranks local to the current Parallel Context
Definition: AMReX_ParallelDescriptor.H:243
ULong DefaultGpuSeed()
Definition: AMReX_Random.H:230
Definition: AMReX_Amr.cpp:49
void FillRandomNormal(MultiFab &mf, int scomp, int ncomp, Real mean, Real stddev)
Fill MultiFab with random numbers from normal distribution.
Definition: AMReX_MultiFabUtil.cpp:1212
void FillRandom(MultiFab &mf, int scomp, int ncomp)
Fill MultiFab with random numbers from uniform distribution.
Definition: AMReX_MultiFabUtil.cpp:1199
void InitRandom(ULong cpu_seed, int nprocs, ULong gpu_seed)
Set the seed of the random number generator.
Definition: AMReX_Random.cpp:89
unsigned int Random_int(unsigned int n)
Generates one pseudorandom unsigned integer which is uniformly distributed on [0,n-1]-interval for ea...
Definition: AMReX_Random.cpp:144
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > log(const GpuComplex< T > &a_z) noexcept
Complex natural logarithm function.
Definition: AMReX_GpuComplex.H:408
Real Random()
Generate a psuedo-random double from uniform distribution.
Definition: AMReX_Random.cpp:123
void ResetRandomSeed(ULong cpu_seed, ULong gpu_seed)
Definition: AMReX_Random.cpp:212
Real RandomNormal(Real mean, Real stddev)
Generate a psuedo-random double from a normal distribution.
Definition: AMReX_Random.cpp:116
ULong Random_long(ULong n)
Generates one pseudorandom unsigned long which is uniformly distributed on [0,n-1]-interval for each ...
Definition: AMReX_Random.cpp:151
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
void 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 s...
Definition: AMReX_Random.cpp:190
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > pow(const GpuComplex< T > &a_z, const T &a_y) noexcept
Raise a complex number to a (real) power.
Definition: AMReX_GpuComplex.H:418
unsigned int RandomPoisson(Real lambda)
Generate a psuedo-random integer from a Poisson distribution.
Definition: AMReX_Random.cpp:130
void DeallocateRandomSeedDevArray()
Definition: AMReX_Random.cpp:218
void SaveRandomState(std::ostream &os)
Save and restore random state.
Definition: AMReX_Random.cpp:159
void RestoreRandomState(std::istream &is, int nthreads_old, int nstep_old)
Definition: AMReX_Random.cpp:167
Real RandomGamma(Real alpha, Real beta)
Generate a psuedo-random floating point number from the Gamma distribution.
Definition: AMReX_Random.cpp:137
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > sqrt(const GpuComplex< T > &a_z) noexcept
Return the square root of a complex number.
Definition: AMReX_GpuComplex.H:373
Definition: AMReX_FabArrayCommI.H:896
Definition: AMReX_RandomEngine.H:57
randState_t * rand_state
Definition: AMReX_RandomEngine.H:58