[all-commits] [llvm/llvm-project] 037179: [flang] Support `do concurrent ... reduce` for ass...

Kareem Ergawy via All-commits all-commits at lists.llvm.org
Mon Jul 14 02:34:56 PDT 2025


  Branch: refs/heads/users/ergawy/dc_associate_reduce
  Home:   https://github.com/llvm/llvm-project
  Commit: 037179d9de52eaf2a0f9958dc082c058229209c5
      https://github.com/llvm/llvm-project/commit/037179d9de52eaf2a0f9958dc082c058229209c5
  Author: ergawy <kareem.ergawy at amd.com>
  Date:   2025-07-14 (Mon, 14 Jul 2025)

  Changed paths:
    M flang/lib/Lower/Support/ReductionProcessor.cpp
    M flang/test/Lower/OpenMP/parallel-reduction-array-lb.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-array-assumed-shape.f90
    A flang/test/Lower/do_concurrent_reduce_associate.f90

  Log Message:
  -----------
  [flang] Support `do concurrent ... reduce` for associating names

Extends reduction support for `do concurrent`, in particular, for
associating names. Consider the following input:
```fortran
subroutine dc_associate_reduce
  integer :: i
  real, allocatable, dimension(:) :: x

  associate(x_associate => x)
  do concurrent (i = 1:10) reduce(+: x_associate)
  end do
  end associate
end subroutine
```

The declaration of `x_associate` is emitted as follows:
```mlir
%13:2 = hlfir.declare %10(%12) {uniq_name = "...."} : (!fir.heap<!fir.array<?xf32>>, !fir.shapeshift<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.heap<!fir.array<?xf32>>)
```
where the HLFIR base type is an array descriptor (i.e. the
allocatable/heap attribute is dropped as stipulated by the spec; section
11.1.3.3).

The problem here is that `declare_reduction` ops accept only reference
types. This restriction is alreay partially handed for
`fir::BaseBoxType`'s by allocating a stack slot for the descriptor and
storing the box in that stack allocation. We have to modify this a
littble bit for `associate` since the HLFIR and FIR base types are
different (unlike most scenarios).



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