MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / InitRandom

Function InitRandom

Src/Base/AMReX_Random.cpp:98–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96namespace amrex {
97
98void
99InitRandom (ULong cpu_seed, int nprocs, ULong gpu_seed)
100{
101 nthreads = OpenMP::get_max_threads();
102 generators.resize(nthreads);
103
104#ifdef AMREX_USE_OMP
105 if (omp_in_parallel()) {
106 amrex::Abort("It is not safe to call amrex::InitRandom inside a threaded region.");
107 }
108#endif
109
110#ifdef AMREX_USE_OMP
111#pragma omp parallel
112#endif
113 {
114 int tid = OpenMP::get_thread_num();
115 ULong init_seed = cpu_seed + tid*nprocs;
116 generators[tid].seed(init_seed);
117 }
118
119#ifdef AMREX_USE_GPU
120 ResizeRandomSeed(gpu_seed);
121#else
122 ignore_unused(gpu_seed);
123#endif
124}
125
126Real RandomNormal (Real mean, Real stddev)
127{

Callers 3

InitRandomMethod · 0.85
InitializeMethod · 0.85
ResetRandomSeedFunction · 0.85

Calls 5

get_max_threadsFunction · 0.85
AbortFunction · 0.85
get_thread_numFunction · 0.85
ResizeRandomSeedFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected