[all-commits] [llvm/llvm-project] 6333f8: [flang][OpenMP] Move reductions from `loop` to `te...

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Thu Apr 3 21:21:12 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6333f8457c43f5a2d19d6552689726e86196dea7
      https://github.com/llvm/llvm-project/commit/6333f8457c43f5a2d19d6552689726e86196dea7
  Author: Kareem Ergawy <kareem.ergawy at amd.com>
  Date:   2025-04-04 (Fri, 04 Apr 2025)

  Changed paths:
    M flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp
    M flang/test/Lower/OpenMP/loop-directive.f90

  Log Message:
  -----------
  [flang][OpenMP] Move reductions from `loop` to `teams` when `loop` is mapped to `distribute` (#132920)

Follow-up to #132003, in particular, see
https://github.com/llvm/llvm-project/pull/132003#issuecomment-2739701936.

This PR extends reduction support for `loop` directives. Consider the
following scenario:
```fortran
subroutine bar
  implicit none
  integer :: x, i

  !$omp teams loop reduction(+: x)
  DO i = 1, 5
    call foo()
  END DO
end subroutine
```
Note the following:
* According to the spec, the `reduction` clause will be attached to
`loop` during earlier stages in the compiler.
* Additionally, `loop` cannot be mapped to `distribute parallel for` due
to the call to a foreign function inside the loop's body.
* Therefore, `loop` must be mapped to `distribute`.
* However, `distribute` does not have `reduction` clauses.
* As a result, we have to move the `reduction`s from the `loop` to its
parent `teams` directive, which is what is done by this PR.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list