| 96 | namespace amrex { |
| 97 | |
| 98 | void |
| 99 | InitRandom (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 | |
| 126 | Real RandomNormal (Real mean, Real stddev) |
| 127 | { |
no test coverage detected