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

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Wed Nov 26 02:59:43 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f481f5bef90d0dd10a9d885b2e4bbfd015e6606d
      https://github.com/llvm/llvm-project/commit/f481f5bef90d0dd10a9d885b2e4bbfd015e6606d
  Author: Kareem Ergawy <kareem.ergawy at amd.com>
  Date:   2025-11-26 (Wed, 26 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 llvm/unittests/Frontend/OpenMPIRBuilderTest.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 (#165714)

Adds initial support for GPU by-ref reductions. The main problem for
reduction by reference is that, prior to this PR, we were shuffling
(from remote lanes within the same warp or across different warps within
the block) pointers/references to the private reduction values rather
than the private reduction values themselves.

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