[flang-commits] [flang] [flang][OpenMP] Do not emit barrier after SECTIONS with LASTPRIVATE and NOWAIT (PR #216018)
via flang-commits
flang-commits at lists.llvm.org
Thu Aug 13 06:41:27 PDT 2026
================
@@ -3727,16 +3937,9 @@ genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
// Perform DataSharingProcessor's step2 out of SECTIONS
builder.setInsertionPointAfter(sectionsOp.getOperation());
dsp.processStep2(sectionsOp, false);
- // Emit barrier when nowait is present and there are lastprivate copy-backs
- // (either non-conditional or conditional). The barrier ensures all threads
- // have completed their work before lastprivate values are read/copied.
- //
- // NOTE: The LLVM OpenMP runtime currently imposes an implicit barrier
- // inside __kmpc_reduce for tree reductions. If the runtime were modified
- // to release losing threads early when nowait is specified, we could use
- // the return value from the tree reduction (case 1 = winner) to let the
- // winner thread perform the copy-back without a separate barrier.
- if (clauseOps.nowait && (hasNonCondLastprivate || !condLpSyms.empty()))
+ // Emit barrier when nowait is present and conditional lastprivate reduction
+ // results must be finalized before copy-back.
+ if (clauseOps.nowait && !condLpSyms.empty())
----------------
Ritanya-B-Bharadwaj wrote:
Non-blocking nit: maybe note in the description (or here) that the barrier still shown in the `firstprivate lastprivate` test is that pre-construct one, so it's clear the removed one wasn't load-bearing.
https://github.com/llvm/llvm-project/pull/216018
More information about the flang-commits
mailing list