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

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Fri Oct 31 03:12:56 PDT 2025


  Branch: refs/heads/users/ergawy/allocatable_reduction_irbuilder
  Home:   https://github.com/llvm/llvm-project
  Commit: 1fdd4e700c9f77f927e65f291b055e3f7ce3bca2
      https://github.com/llvm/llvm-project/commit/1fdd4e700c9f77f927e65f291b055e3f7ce3bca2
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-10-31 (Fri, 31 Oct 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.



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