[flang-commits] [flang] [flang][OpenMP] Fix construct privatization in default clause (PR #72510)

via flang-commits flang-commits at lists.llvm.org
Tue Mar 26 04:11:03 PDT 2024


NimishMishra wrote:

> A possible solution could be to visit nested evaluations recursively and, in each one, collect the symbols from the first OpenMP construct (if any).

Hi @luporl,

   I am revisiting this patch, and am wondering if recursion is needed here. Checking up with you once if I am missing something.

```
!$omp parallel do default(private) firstprivate(y)
  do i = 1, 10
    y = 1           ! Point X
    !$omp parallel default(private)
      y = 2        ! Point Y
    !$omp end parallel
  end do
!$omp end parallel do
end
```

Then `collectSymbolSet()` on the outermost evaluation shall collect all symbols within the region. Then we enter into its nested evaluations and catch `do{... region ...}`, which is essentially,

```
do{
     assignment-stmt
     parallel{... region ...}
}
```

So if we iterate over these evaluations, and do the following:

1. For non-OpenMP constructs, skip adding symbols to `symbolsInNestedRegion`. This shall skip the symbol `y` marked at `Point X`.
2. For OpenMP constructs, add symbols. This shall add the symbol `y` marked at `Point Y`.

Concisely, for a `do{... region ...}`, if we have a OpenMP region inside it, then we can add **all** symbols within it to `symbolsInNestedRegion` with just one `collectSymbolSet` call (which in turn is recursive). So I was wondering if we need additional recursion at this point.

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


More information about the flang-commits mailing list