Skip to content
Merged
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
19 changes: 18 additions & 1 deletion Src/Particle/AMReX_ParticleContainerI.H
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,7 @@ addParticles (const PCType& other, F const& f, bool local)
{
BL_PROFILE("ParticleContainer::addParticles");

// touch all tiles in serial
for (int lev = 0; lev < other.numLevels(); ++lev)
{
const auto& plevel_other = other.GetParticles(lev);
Expand All @@ -1174,7 +1175,23 @@ addParticles (const PCType& other, F const& f, bool local)
auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
if(plevel_other.find(index) == plevel_other.end()) { continue; }

auto& ptile = DefineAndReturnParticleTile(lev, mfi.index(), mfi.LocalTileIndex());
DefineAndReturnParticleTile(lev, mfi.index(), mfi.LocalTileIndex());
}
}

#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (int lev = 0; lev < other.numLevels(); ++lev)
{
const auto& plevel_other = other.GetParticles(lev);
for(MFIter mfi = other.MakeMFIter(lev); mfi.isValid(); ++mfi)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not related to OpeMP. But we could use this version MFIter MakeMFIter (int lev, const MFItInfo& info) const to disable gpu device sync here and above. If we disable it here, we need to add Gpu::streamSynchronizeAll() after the loop over levels.

Do you want to do this in a follow-up or this PR?

This comment was marked as off-topic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try this in a follow-on PR.

{
auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
if(plevel_other.find(index) == plevel_other.end()) { continue; }

// this has already had define() called above
auto& ptile = ParticlesAt(lev, mfi.index(), mfi.LocalTileIndex());
const auto& ptile_other = plevel_other.at(index);
auto np = ptile_other.numParticles();
if (np == 0) { continue; }
Expand Down
Loading