aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/PhysicalParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Weiqun Zhang <WeiqunZhang@lbl.gov> 2020-09-25 08:24:13 -0700
committerGravatar GitHub <noreply@github.com> 2020-09-25 08:24:13 -0700
commit20d2d2df343bc672316deb76c1088fb44cc0cf93 (patch)
tree7d47c25d8ac17b531b56e705bc079db27052a967 /Source/Particles/PhysicalParticleContainer.cpp
parentfc898a05abd9fc2cba6f087e865415379174bab9 (diff)
downloadWarpX-20d2d2df343bc672316deb76c1088fb44cc0cf93.tar.gz
WarpX-20d2d2df343bc672316deb76c1088fb44cc0cf93.tar.zst
WarpX-20d2d2df343bc672316deb76c1088fb44cc0cf93.zip
Use amrex::ParallelForRNG for random number generation (#1373)
* Use amrex::ParallelForRNG for random number generation In order to support RNG on non-Nvidia GPUs, we need to use amrex::ParallelForRNG for kernels with calls to AMReX random number generation functions. * missing a RandomEngine argument
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 0f0ac96f5..28e0ca703 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -753,7 +753,8 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
// The invalid ones are given negative ID and are deleted during the
// next redistribute.
const auto poffset = offset.data();
- amrex::For(overlap_box, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
+ amrex::ParallelForRNG(overlap_box,
+ [=] AMREX_GPU_DEVICE (int i, int j, int k, amrex::RandomEngine const& engine) noexcept
{
IntVect iv = IntVect(AMREX_D_DECL(i, j, k));
const auto index = overlap_box.index(iv);
@@ -765,7 +766,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
p.cpu() = cpuid;
const XDim3 r =
- inj_pos->getPositionUnitBox(i_part, lrrfac);
+ inj_pos->getPositionUnitBox(i_part, lrrfac, engine);
auto pos = getCellCoords(overlap_corner, dx, r, iv);
#if (AMREX_SPACEDIM == 3)
@@ -793,7 +794,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
if (nmodes == 1) {
// With only 1 mode, the angle doesn't matter so
// choose it randomly.
- theta = 2._rt*MathConst::pi*amrex::Random();
+ theta = 2._rt*MathConst::pi*amrex::Random(engine);
} else {
theta = 2._rt*MathConst::pi*r.y;
}
@@ -817,7 +818,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
continue;
}
- u = inj_mom->getMomentum(pos.x, pos.y, z0);
+ u = inj_mom->getMomentum(pos.x, pos.y, z0, engine);
dens = inj_rho->getDensity(pos.x, pos.y, z0);
// Remove particle if density below threshold
@@ -849,7 +850,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
dens = amrex::min(dens, density_max);
// get the full momentum, including thermal motion
- u = inj_mom->getMomentum(pos.x, pos.y, 0._rt);
+ u = inj_mom->getMomentum(pos.x, pos.y, 0._rt, engine);
const Real gamma_lab = std::sqrt( 1._rt+(u.x*u.x+u.y*u.y+u.z*u.z) );
const Real betaz_lab = u.z/(gamma_lab);
@@ -869,7 +870,7 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
}
if(loc_has_breit_wheeler){
- p_optical_depth_BW[ip] = breit_wheeler_get_opt();
+ p_optical_depth_BW[ip] = breit_wheeler_get_opt(engine);
}
#endif