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

CarpetX: only multi-thread MFIter if AMReX supports it #176

Closed
wants to merge 1 commit into from

Conversation

rhaas80
Copy link
Member

@rhaas80 rhaas80 commented Jul 23, 2023

This adds a couple of #ifdef AMP_USE_OPENMP around pragma omp parallel to avoid calling AMReX functions from within OpenMP parallel sections if AMReX itself is not compiled with OpenMP support (and thus eg fails to check for nested MFIter instantiations only on a single thread).

The code that would trigger this is in AMReX Src/Base/AMReX_MFIter.cpp:

#ifdef AMREX_USE_OMP
#pragma omp master
#endif
    {
        ++depth;
        AMREX_ALWAYS_ASSERT_WITH_MESSAGE(depth == 1 || MFIter::allow_multiple_mfiters,
            "Nested or multiple active MFIters is not supported by default.  This can be changed by calling MFIter::allowMultipleMFIters(true)".);
    }

and AMReX user code like this:

#pragma omp parallel
for(MFIter mfi(foo) ; ...)

will trigger the error since the parallel section causes a MFIter object to be created in each thread and without AMREX_USE_OMP AMReX will trigger the depth == 1 test on all threads instead of just the master thread.

@rhaas80 rhaas80 added the bug Something isn't working label Jul 23, 2023
@rhaas80
Copy link
Member Author

rhaas80 commented Jul 26, 2023

@eschnett says (private conversation) to rather abort build if OpenMP capabilities between CarpetX and AMReX do not match.

@rhaas80 rhaas80 closed this Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant