Skip to content
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

Assert no nested MFIters #1530

Merged
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
1 change: 1 addition & 0 deletions Src/Base/AMReX_MFIter.H
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ protected:
#endif

static int nextDynamicIndex;
static int depth;

void Initialize ();
};
Expand Down
16 changes: 16 additions & 0 deletions Src/Base/AMReX_MFIter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace amrex {

int MFIter::nextDynamicIndex = std::numeric_limits<int>::min();
int MFIter::depth = 0;

MFIter::MFIter (const FabArrayBase& fabarray_,
unsigned char flags_)
Expand Down Expand Up @@ -200,6 +201,13 @@ MFIter::MFIter (const FabArrayBase& fabarray_, const MFItInfo& info)

MFIter::~MFIter ()
{
#ifdef _OPENMP
#pragma omp master
#endif
{
depth = 0;
}

#ifdef BL_USE_TEAM
if ( ! (flags & NoTeamBarrier) )
ParallelDescriptor::MyTeam().MemoryBarrier();
Expand Down Expand Up @@ -242,6 +250,14 @@ MFIter::~MFIter ()
void
MFIter::Initialize ()
{
#ifdef _OPENMP
#pragma omp master
#endif
{
++depth;
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(depth == 1, "Nested MFIter is not supported");
}

if (flags & SkipInit) {
return;
}
Expand Down