[all-commits] [llvm/llvm-project] 186336: [OpenMP][flang] Add initial support for by-ref red...

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Tue Nov 25 03:11:22 PST 2025


  Branch: refs/heads/users/ergawy/allocatable_reduction_irbuilder
  Home:   https://github.com/llvm/llvm-project
  Commit: 18633662066df938c862cbd89e79f26c49e19587
      https://github.com/llvm/llvm-project/commit/18633662066df938c862cbd89e79f26c49e19587
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-25 (Tue, 25 Nov 2025)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
    M flang/include/flang/Optimizer/Dialect/FIROps.td
    M flang/lib/Lower/Support/ReductionProcessor.cpp
    M flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
    M flang/test/Lower/OpenMP/delayed-privatization-reduction-byref.f90
    M flang/test/Lower/OpenMP/parallel-reduction-allocatable-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90
    M flang/test/Lower/OpenMP/parallel-reduction-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction-array2.f90
    M flang/test/Lower/OpenMP/parallel-reduction-pointer-array.f90
    M flang/test/Lower/OpenMP/parallel-reduction3.f90
    M flang/test/Lower/OpenMP/reduction-array-intrinsic.f90
    M flang/test/Lower/OpenMP/sections-array-reduction.f90
    M flang/test/Lower/OpenMP/taskgroup-task-array-reduction.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-allocatable-array-minmax.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-allocatable.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array-assumed-shape.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array-lb.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array-lb2.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-array2.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-multiple-clauses.f90
    M flang/test/Lower/OpenMP/wsloop-reduction-pointer.f90
    M flang/test/Lower/do_concurrent_reduce_allocatable.f90
    M llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    A mlir/test/Target/LLVMIR/allocatable_gpu_reduction.mlir
    M mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir
    M mlir/test/Target/LLVMIR/omptarget-multi-reduction.mlir
    M mlir/test/Target/LLVMIR/omptarget-teams-distribute-reduction.mlir
    M mlir/test/Target/LLVMIR/omptarget-teams-reduction.mlir

  Log Message:
  -----------
  [OpenMP][flang] Add initial support for by-ref reductions on the GPU

Adds initial support for GPU by-ref reductions. In particular, this diff
adds support for reductions on scalar allocatables where reductions
happen on loops nested in `target` regions. For example:

```fortran
  integer :: i
  real, allocatable :: scalar_alloc

  allocate(scalar_alloc)
  scalar_alloc = 0

  !$omp target map(tofrom: scalar_alloc)
  !$omp parallel do reduction(+: scalar_alloc)
  do i = 1, 1000000
    scalar_alloc = scalar_alloc + 1
  end do
  !$omp end target
```

This PR supports by-ref reductions on the intra- and inter-warp levels.

So far, there are still steps to be takens for full support of by-ref
reductions, for example:
* Support inter-block value combination is still not supported.
  Therefore, `target teams distribute parallel do` is still not
  supported.
* Support for dynamically-sized arrays still needs to be added.
* Support for more than one allocatable/array on the same `reduction`
  clause.


  Commit: af41e990cca2a09f5c1633f949bc5fb1bd56541d
      https://github.com/llvm/llvm-project/commit/af41e990cca2a09f5c1633f949bc5fb1bd56541d
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-25 (Tue, 25 Nov 2025)

  Changed paths:
    M llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

  Log Message:
  -----------
  review comments, Michael


  Commit: 070b6c491b0a62eeadd65af9f4ec8e5a5a41708d
      https://github.com/llvm/llvm-project/commit/070b6c491b0a62eeadd65af9f4ec8e5a5a41708d
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-25 (Tue, 25 Nov 2025)

  Changed paths:
    M flang/lib/Lower/Support/ReductionProcessor.cpp

  Log Message:
  -----------
  review comments, Tom


  Commit: d715c56d4914c511b0f60066cea4040e18935f04
      https://github.com/llvm/llvm-project/commit/d715c56d4914c511b0f60066cea4040e18935f04
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-25 (Tue, 25 Nov 2025)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
    M flang/include/flang/Optimizer/Dialect/FIROps.td
    M flang/lib/Lower/Support/ReductionProcessor.cpp
    M llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
    M llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
    M llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/allocatable_gpu_reduction.mlir
    M mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir

  Log Message:
  -----------
  Add `data_ptr_ptr` region to `declare_reduction` op.


  Commit: ec80eb7cd928951f78c6f2a06464fa1378b09a4a
      https://github.com/llvm/llvm-project/commit/ec80eb7cd928951f78c6f2a06464fa1378b09a4a
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-25 (Tue, 25 Nov 2025)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
    M llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

  Log Message:
  -----------
  try to fix Windows build


  Commit: d6c16a7e2b77de16af0a640d5102958b27cb5f2d
      https://github.com/llvm/llvm-project/commit/d6c16a7e2b77de16af0a640d5102958b27cb5f2d
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-25 (Tue, 25 Nov 2025)

  Changed paths:
    M flang/lib/Lower/Support/ReductionProcessor.cpp

  Log Message:
  -----------
  post-rebase fixes


  Commit: 8f2acf6c7b8a1dc7a47bffa0a09c464b3dd5670c
      https://github.com/llvm/llvm-project/commit/8f2acf6c7b8a1dc7a47bffa0a09c464b3dd5670c
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-25 (Tue, 25 Nov 2025)

  Changed paths:
    M flang/include/flang/Optimizer/Dialect/FIROps.td
    M flang/lib/Lower/Support/ReductionProcessor.cpp
    M mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
    M mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

  Log Message:
  -----------
  review comments, Pranav


Compare: https://github.com/llvm/llvm-project/compare/98751f2995fd...8f2acf6c7b8a

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