[Mlir-commits] [flang] [mlir] [mlir][OpenMP][flang] make private variable allocation implicit in omp.private (PR #124019)

Leandro Lupori llvmlistbot at llvm.org
Thu Feb 13 06:58:58 PST 2025


================
@@ -184,7 +218,8 @@ bool DataSharingProcessor::needBarrier() {
   // Emit implicit barrier for linear clause. Maybe on somewhere else.
   for (const semantics::Symbol *sym : allPrivatizedSymbols) {
     if (sym->test(semantics::Symbol::Flag::OmpLastPrivate) &&
-        (sym->test(semantics::Symbol::Flag::OmpFirstPrivate) || callsInitClone))
+        (sym->test(semantics::Symbol::Flag::OmpFirstPrivate) ||
+         mightHaveReadHostSym))
----------------
luporl wrote:

AFAIU, a barrier should not be needed in this case, since it is not possible to have concurrent read/write of the same memory region, as `i` is only written to in the last iteration and, as it seems, `x` is only read during privatization (this could probably be optimized, since `x`'s shape is known at compile time).

I hadn't noticed it before, but having a single `mightHaveReadHostSym` variable for all privatized symbols is a problem indeed. A possible solution would be to have a per-symbol `mightHaveReadHostSym`.

https://github.com/llvm/llvm-project/pull/124019


More information about the Mlir-commits mailing list