Skip to content

fix random number signature #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Source/Initialization/PlasmaInjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,11 @@ amrex::XDim3 PlasmaInjector::getMomentum (amrex::Real x,
amrex::Real y,
amrex::Real z) const noexcept
{
#ifdef AMREX_USE_GPU
return h_inj_mom->getMomentum(x, y, z, amrex::RandomEngine{nullptr}); // gamma*beta
#else
return h_inj_mom->getMomentum(x, y, z, amrex::RandomEngine{}); // gamma*beta
#endif
}

bool PlasmaInjector::insideBounds (amrex::Real x, amrex::Real y, amrex::Real z) const noexcept
Expand Down
6 changes: 5 additions & 1 deletion Source/Particles/ParticleBoundaryBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,11 @@ void ParticleBoundaryBuffer::gatherParticles (MultiParticleContainer& mypc,
amrex::ReduceData<int> reduce_data(reduce_op);
{
WARPX_PROFILE("ParticleBoundaryBuffer::gatherParticles::count_out_of_bounds");
amrex::RandomEngine rng{};
#ifdef AMREX_USE_GPU
const amrex::RandomEngine rng{nullptr};
#else
const amrex::RandomEngine rng{};
#endif
reduce_op.eval(np, reduce_data, [=] AMREX_GPU_HOST_DEVICE (int ip)
{ return predicate(ptile_data, ip, rng) ? 1 : 0; });
}
Expand Down
5 changes: 5 additions & 0 deletions Source/Particles/WarpXParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,13 @@ WarpXParticleContainer::AddNParticles (int /*lev*/,
}

// Default initialize the other real and integer runtime attributes
#ifdef AMREX_USE_GPU
DefaultInitializeRuntimeAttributes(pinned_tile, nattr_real - 1, nattr_int,
amrex::RandomEngine{nullptr});
#else
DefaultInitializeRuntimeAttributes(pinned_tile, nattr_real - 1, nattr_int,
amrex::RandomEngine{});
#endif

auto old_np = particle_tile.numParticles();
auto new_np = old_np + pinned_tile.numParticles();
Expand Down
Loading