[flang-commits] [flang] [flang][OpenMP] Clone reduction info from nested `loop` ops to parent `teams` ops (PR #132003)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Thu Mar 20 02:20:33 PDT 2025
ergawy wrote:
I am wondering, howerver, what we should do in these 2 scearios:
```fortran
subroutine scenario_1
implicit none
integer :: x, i
!$omp loop reduction(+: x) bind(teams)
DO i = 1, 5
call foo()
END DO
end subroutine
```
The above scenario is problematic because, AFAICT, this is allowed by the spec (it is allowed by flang atm) but there is no construct to lift the reductions to.
```fortran
subroutine scenario_2
implicit none
integer :: x, i
!$omp teams loop reduction(+: x)
DO i = 1, 5
call foo()
END DO
end subroutine
```
This one is easier, I think we just lift reductions to the `teams` construct and skip the them when converting `loop` to `distribute` later on (note that `loop` cannot be mapped to `parallel for` here since its loop nest contains a call to a foreign function). So we need to extend this PR to handle reduction skipping part.
@mjklemm @jsjodin please take a look and let me know what you think.
https://github.com/llvm/llvm-project/pull/132003
More information about the flang-commits
mailing list