[all-commits] [llvm/llvm-project] 9cc735: [flang][OpenMP][HLFIR] Support vector subscripted ...
Tom Eccles via All-commits
all-commits at lists.llvm.org
Tue Apr 1 03:04:00 PDT 2025
Branch: refs/heads/users/tblah/array-sections-02-vector-subscript
Home: https://github.com/llvm/llvm-project
Commit: 9cc7354d00b5f030869597269fa731fe0059af1d
https://github.com/llvm/llvm-project/commit/9cc7354d00b5f030869597269fa731fe0059af1d
Author: Tom Eccles <tom.eccles at arm.com>
Date: 2025-04-01 (Tue, 01 Apr 2025)
Changed paths:
M flang/include/flang/Optimizer/HLFIR/HLFIROps.td
M flang/lib/Lower/OpenMP/ClauseProcessor.cpp
R flang/test/Lower/OpenMP/Todo/depend-clause-vector-subscript-array-section.f90
M flang/test/Lower/OpenMP/task-depend-array-section.f90
Log Message:
-----------
[flang][OpenMP][HLFIR] Support vector subscripted array sections for DEPEND
The OpenMP runtime needs the base address of the array section to
identify the dependency.
If we just put the vector subscript through the usual HLFIR expression
lowering, that would generate a new contiguous array representing the
values of the elements in the array which was sectioned. We cannot use
addresses from this array because these addresses would not match
dependencies on the original array. For example
```
integer :: array(1024)
integer :: indices(2)
indices(1) = 1
indices(2) = 100
!$omp task depend(out: array(1:512))
!$omp end task
!$omp task depend(in: array(indices))
!$omp end task
```
This requires taking the lowering path previously only used for ordered
assignments to get the address of the elements in the original array
which were indexed. This is done using `hlfir.elemental_addr`. e.g.
```
array(indices) = 2
```
`hlfir.elemental_addr` is awkward to use because it (by design) doesn't
return something like `!hlfir.expr<>` (like `hlfir.elemental`) and so
it can't have a generic lowering: each place it is used has to
carefully inline the contents of the operation and extract the needed
address.
For this reason, `hlfir.elemental_addr` was not previously allowed
outside of these ordered assignments. In this commit I relax that
restriction so that I can use `hlfir.elemental_addr` to lower the OpenMP
DEPEND clause. The disadvantage of doing so is that there is no generic
lowering supporting uses of `hlfir.elemental_addr` in arbitrary
contexts. I think it is okay to have this gap in the dialect verifier
because HLFIR is not a dialect shared with users outside of flang.
One alternative solution would have been to provide my own more limited
re-implementation of `HlfirDesignatorBuilder` which skipped
`hlfir::elemental_addr`, instead inlining its body directly at the
current insertion point applying indices only for the first element. This
would have been difficult to maintain because designation in Fortran is
complex.
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