[flang-commits] [flang] [flang][OpenMP] Try to unify induction var privatization for sequential loops inside parallel regions. (PR #91116)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Tue May 7 06:40:20 PDT 2024


================
@@ -344,7 +353,6 @@ void DataSharingProcessor::collectSymbols(
     assert(curScope && "couldn't find current scope");
     if (isPrivatizable(*sym) && !symbolsInNestedRegions.contains(sym) &&
         !privatizedSymbols.contains(sym) &&
-        !sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined) &&
----------------
luporl wrote:

I've added this test to make `defaultSymbols` and `implicitSymbols` more accurate and to simplify `defaultPrivatize` and `implicitPrivatize`.

Also, implicit symbols (those whose DSA is implicitly determined) are only present when there are no default symbols in a given construct (see`collectImplicitSymbols`). If pre-determined symbols are included in `defaultSymbols` we can no longer know what is the set of default symbols.

Finally, in the non-delayed privatization path, pre-determined symbols were already being skipped:
```c++
void DataSharingProcessor::cloneSymbol(const Fortran::semantics::Symbol *sym) {
  // Privatization for symbols which are pre-determined (like loop index
  // variables) happen separately, for everything else privatize here.
  if (sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
    return;
```

As pre-determined symbols' DSAs don't depend on default clauses, I don't think they should be handled as default or implicit symbols. In your test program, if you remove `default(private)`, are induction variables correctly privatized?

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


More information about the flang-commits mailing list