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

Function FillRandom

Src/Base/AMReX_Random.cpp:263–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263void FillRandom (Real* p, Long N)
264{
265#ifdef AMREX_USE_CUDA
266
267# ifdef BL_USE_FLOAT
268 AMREX_CURAND_SAFE_CALL(curandGenerateUniform(gpu_rand_generator, p, N));
269# else
270 AMREX_CURAND_SAFE_CALL(curandGenerateUniformDouble(gpu_rand_generator, p, N));
271# endif
272 Gpu::synchronize();
273
274#elif defined(AMREX_USE_HIP)
275
276# ifdef BL_USE_FLOAT
277 AMREX_HIPRAND_SAFE_CALL(hiprandGenerateUniform(gpu_rand_generator, p, N));
278# else
279 AMREX_HIPRAND_SAFE_CALL(hiprandGenerateUniformDouble(gpu_rand_generator, p, N));
280# endif
281 Gpu::synchronize();
282
283#elif defined(AMREX_USE_SYCL)
284
285 oneapi::mkl::rng::uniform<Real> distr;
286 auto event = oneapi::mkl::rng::generate(distr, *gpu_rand_generator, N, p);
287 event.wait();
288
289#else
290 std::uniform_real_distribution<Real> distribution(Real(0.0), Real(1.0));
291 auto& gen = generators[OpenMP::get_thread_num()];
292 for (Long i = 0; i < N; ++i) {
293 p[i] = distribution(gen);
294 }
295#endif
296}
297
298void FillRandomNormal (Real* p, Long N, Real mean, Real stddev)
299{

Callers 1

mainFunction · 0.50

Calls 3

synchronizeFunction · 0.85
get_thread_numFunction · 0.85
waitMethod · 0.45

Tested by

no test coverage detected