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

Michael Klemm via flang-commits flang-commits at lists.llvm.org
Mon Feb 5 01:03:44 PST 2024


mjklemm wrote:

I have commented the correct data sharing for the given example as comments in the code:

```Fortran
program mn
  call sb1()
contains
 subroutine sb1()
   integer :: x 
   x = 20
   !$omp parallel default(private)  ! x is declare outside of the region, so it's shared by default, default(private) changes this to private
   !$omp parallel  ! the private x of the outer region is "declared" outside of this region, thus it's shared for the nested region
   x = 30
   !$omp end parallel
   !$omp end parallel
   print *, x
 end subroutine
end program
```

So, all OpenMP constructs that may take data-sharing attribute clauses may sort of have an implicit default data-sharing attribute or inherit from the outer scope.  For instance, `parallel` uses the implicit default data-sharing attribute, while `critical` just uses what's coming from the outer scope.

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


More information about the flang-commits mailing list