Commit e748dc5
committed
[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.1 parent 4c09ae0 commit e748dc5
File tree
4 files changed
+86
-24
lines changed- flang
- include/flang/Optimizer/HLFIR
- lib/Lower/OpenMP
- test/Lower/OpenMP
- Todo
4 files changed
+86
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1419 | 1419 | | |
1420 | 1420 | | |
1421 | 1421 | | |
1422 | | - | |
| 1422 | + | |
1423 | 1423 | | |
1424 | 1424 | | |
1425 | 1425 | | |
1426 | 1426 | | |
1427 | | - | |
1428 | | - | |
| 1427 | + | |
| 1428 | + | |
1429 | 1429 | | |
1430 | 1430 | | |
1431 | 1431 | | |
1432 | 1432 | | |
1433 | 1433 | | |
1434 | 1434 | | |
1435 | | - | |
1436 | | - | |
| 1435 | + | |
1437 | 1436 | | |
1438 | 1437 | | |
1439 | 1438 | | |
1440 | 1439 | | |
1441 | 1440 | | |
1442 | | - | |
1443 | | - | |
| 1441 | + | |
1444 | 1442 | | |
1445 | 1443 | | |
1446 | 1444 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
889 | 889 | | |
890 | 890 | | |
891 | 891 | | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | 892 | | |
896 | | - | |
897 | | - | |
898 | | - | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
899 | 941 | | |
900 | 942 | | |
901 | 943 | | |
| |||
Lines changed: 0 additions & 11 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
0 commit comments