Repository navigation
Conversation
…e sub-solvers bjprecond_apply opened `!$omp parallel if(thread_safe)` around the local sub-solves. With SuperLU-DIST (or MUMPS) the region is inactive, but it still makes every OpenMP team created inside the library a nested team. On targets where libgomp uses its POSIX barrier (eg. macOS), nested teams that create explicit tasks (SuperLU-DIST pdgstrs2_omp) can leave stray wake-ups that release the nested-team teardown barrier early. The freed team is then reused while a worker is still waiting on it, which leads to early thread release and eventually a deadlock. This caused the test_LU_*nlocal2*[2] tests to hang with OMP_NUM_THREADS=2 when SuperLU-DIST is built with OpenMP (eg. via PETSc --with-openmp). Only open the parallel region when the sub-solver is thread safe. The per-part loop moves to a contained routine with an orphaned work-sharing loop so it runs the same either way. No API or input file changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Opened against the upstream repository instead: OpenFUSIONToolkit#450 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
bjprecond_applynow opens its OpenMP parallel region only when the sub-solver is thread safe. When it is not (superd,mumps), the local sub-solves run with no enclosing region at all, so OpenMP teams created inside those libraries are top-level rather than nested.The per-part loop moved into a contained routine,
apply_parts, that uses an orphaned!$omp do, so the same code runs inside or outside the region.No API or input file changes.
Why
With SuperLU-DIST built with OpenMP (eg. by PETSc
--with-openmp), thetest_native_bjacobi.py::test_LU_*nlocal2*[2]tests hang atOMP_NUM_THREADS=2on macOS with GCC 16. They pass with 1 thread orOMP_DYNAMIC=true. All PETSc versions 3.20–3.24 are affected.The cause is a libgomp bug in the POSIX barrier implementation it uses on Darwin (no futex):
GOMP_taskposts a wake-up token to the barrier semaphore for each task, whether or not a thread is waiting. SuperLU-DIST'spdgstrs2_omp, called frompdgstrf, creates tasks.gomp_team_endwaits withgomp_barrier_wait, and each worker withgomp_barrier_wait_last. On POSIX that barrier has no generation check, so a leftover task token lets the master leave early and free the team.The old
!$omp parallel if(thread_safe)region was inactive forsuperd, but even an inactive region makes inner teams nested, which is enough to trigger this.parallel for+omp task) reproduces the hang without OFT, MPI, or SuperLU-DIST.--with-openmptimeouts) and TokaMaker: Is it possible to have a coil at the magnetic axis of the plasma? OpenFUSIONToolkit/OpenFUSIONToolkit#159 (macOS OpenMP corruption).Nothing has been reported to GCC yet.
Testing
Scratch builds on macOS with gcc-16 and MPICH, running
test_native_bjacobi.pyandtest_solver_xml.pywithOMP_NUM_THREADS=2and1:superdtests hangtest_LU_*nlocal2*[2]pass)[2]tests hang (ERRCODE -9)[2]tests hang (ERRCODE -9)Skipped tests use solver packages that were not built.
generate_stack.py -lis clean.Notes for reviewers
schedule(dynamic,1).bjprecond_applywas the onlyif(thread_safe)region found. Any other code path that calls a SuperLU-DIST or MUMPS solve from inside a parallel region could still hit this libgomp bug.🤖 Generated with Claude Code