[all-commits] [llvm/llvm-project] 39740f: [flang][OpenMP] Move reductions `loop` to `teams` ...

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


  Branch: refs/heads/users/ergawy/loop_to_distribute_reduction
  Home:   https://github.com/llvm/llvm-project
  Commit: 39740f6bac14b955425f2a0d049a4c9f13efe12c
      https://github.com/llvm/llvm-project/commit/39740f6bac14b955425f2a0d049a4c9f13efe12c
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-04-03 (Thu, 03 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 `loop` to `teams` when `loop` is mapped to `distribute`

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.


  Commit: d368f44241a5ca3d557af4f3ff2a922615e3e0cc
      https://github.com/llvm/llvm-project/commit/d368f44241a5ca3d557af4f3ff2a922615e3e0cc
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-04-03 (Thu, 03 Apr 2025)

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

  Log Message:
  -----------
  handle review comments


Compare: https://github.com/llvm/llvm-project/compare/008ca28370d1...d368f44241a5

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