Skip to content

Commit 6e26cad

Browse files
authored
Merge pull request #123 from ajnonaka/random_fix
fix random number signature
2 parents e68c75f + cc335e6 commit 6e26cad

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Source/Initialization/PlasmaInjector.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,11 @@ amrex::XDim3 PlasmaInjector::getMomentum (amrex::Real x,
691691
amrex::Real y,
692692
amrex::Real z) const noexcept
693693
{
694+
#ifdef AMREX_USE_GPU
695+
return h_inj_mom->getMomentum(x, y, z, amrex::RandomEngine{nullptr}); // gamma*beta
696+
#else
694697
return h_inj_mom->getMomentum(x, y, z, amrex::RandomEngine{}); // gamma*beta
698+
#endif
695699
}
696700

697701
bool PlasmaInjector::insideBounds (amrex::Real x, amrex::Real y, amrex::Real z) const noexcept

Source/Particles/ParticleBoundaryBuffer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ void ParticleBoundaryBuffer::gatherParticles (MultiParticleContainer& mypc,
251251
amrex::ReduceData<int> reduce_data(reduce_op);
252252
{
253253
WARPX_PROFILE("ParticleBoundaryBuffer::gatherParticles::count_out_of_bounds");
254-
amrex::RandomEngine rng{};
254+
#ifdef AMREX_USE_GPU
255+
const amrex::RandomEngine rng{nullptr};
256+
#else
257+
const amrex::RandomEngine rng{};
258+
#endif
255259
reduce_op.eval(np, reduce_data, [=] AMREX_GPU_HOST_DEVICE (int ip)
256260
{ return predicate(ptile_data, ip, rng) ? 1 : 0; });
257261
}

Source/Particles/WarpXParticleContainer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,13 @@ WarpXParticleContainer::AddNParticles (int /*lev*/,
280280
}
281281

282282
// Default initialize the other real and integer runtime attributes
283+
#ifdef AMREX_USE_GPU
284+
DefaultInitializeRuntimeAttributes(pinned_tile, nattr_real - 1, nattr_int,
285+
amrex::RandomEngine{nullptr});
286+
#else
283287
DefaultInitializeRuntimeAttributes(pinned_tile, nattr_real - 1, nattr_int,
284288
amrex::RandomEngine{});
289+
#endif
285290

286291
auto old_np = particle_tile.numParticles();
287292
auto new_np = old_np + pinned_tile.numParticles();

0 commit comments

Comments
 (0)