Skip to content

Commit fb0b093

Browse files
authored
Delay some synchronize calls in addParticles (#4623)
The proposed changes: - [ ] fix a bug or incorrect behavior in AMReX - [ ] add new capabilities to AMReX - [ ] changes answers in the test suite to more than roundoff level - [ ] are likely to significantly affect the results of downstream AMReX users - [ ] include documentation in the code and/or rst files, if appropriate
1 parent 7886010 commit fb0b093

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Src/Particle/AMReX_ParticleContainerI.H

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,22 +1170,23 @@ addParticles (const PCType& other, F const& f, bool local)
11701170
for (int lev = 0; lev < other.numLevels(); ++lev)
11711171
{
11721172
const auto& plevel_other = other.GetParticles(lev);
1173-
for(MFIter mfi = other.MakeMFIter(lev); mfi.isValid(); ++mfi)
1173+
for(MFIter mfi = other.MakeMFIter(lev, MFItInfo().DisableDeviceSync()); mfi.isValid(); ++mfi)
11741174
{
11751175
auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
11761176
if(plevel_other.find(index) == plevel_other.end()) { continue; }
11771177

11781178
DefineAndReturnParticleTile(lev, mfi.index(), mfi.LocalTileIndex());
11791179
}
11801180
}
1181+
Gpu::streamSynchronizeAll();
11811182

11821183
#ifdef AMREX_USE_OMP
11831184
#pragma omp parallel if (Gpu::notInLaunchRegion())
11841185
#endif
11851186
for (int lev = 0; lev < other.numLevels(); ++lev)
11861187
{
11871188
const auto& plevel_other = other.GetParticles(lev);
1188-
for(MFIter mfi = other.MakeMFIter(lev); mfi.isValid(); ++mfi)
1189+
for(MFIter mfi = other.MakeMFIter(lev, MFItInfo().DisableDeviceSync()); mfi.isValid(); ++mfi)
11891190
{
11901191
auto index = std::make_pair(mfi.index(), mfi.LocalTileIndex());
11911192
if(plevel_other.find(index) == plevel_other.end()) { continue; }
@@ -1204,6 +1205,7 @@ addParticles (const PCType& other, F const& f, bool local)
12041205
ptile.resize(dst_index + count);
12051206
}
12061207
}
1208+
Gpu::streamSynchronizeAll();
12071209

12081210
if (! local) { Redistribute(); }
12091211
}

0 commit comments

Comments
 (0)