forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flang][OpenMP] Handle expressions in
target ... do
loop control (#107
) When emitting the ops required to compute the target loop's trip count, flang might emit ops outside the target regions that operands defined inside the region. This is fixed up by `HostClausesInsertionGuard` already. However, the current support only handles simple cases. If the loop control contains more elaborate expressions, the fix up logic does not handle it properly. This PR handles such cases.
- Loading branch information
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
! Verifies that if expressions are used to compute a target parallel loop, that | ||
! no values escape the target region when flang emits the ops corresponding to | ||
! these expressions (for example the compute the trip count for the target region). | ||
|
||
! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
||
subroutine foo(upper_bound) | ||
implicit none | ||
integer :: upper_bound | ||
integer :: nodes(1 : upper_bound) | ||
integer :: i | ||
|
||
!$omp target teams distribute parallel do | ||
do i = 1, ubound(nodes,1) | ||
nodes(i) = i | ||
end do | ||
!$omp end target teams distribute parallel do | ||
end subroutine | ||
|
||
! CHECK: func.func @_QPfoo(%[[FUNC_ARG:.*]]: !fir.ref<i32> {fir.bindc_name = "upper_bound"}) { | ||
! CHECK: %[[UB_ALLOC:.*]] = fir.alloca i32 | ||
! CHECK: fir.dummy_scope : !fir.dscope | ||
! CHECK: %[[UB_DECL:.*]]:2 = hlfir.declare %[[FUNC_ARG]] {{.*}} {uniq_name = "_QFfooEupper_bound"} | ||
|
||
! CHECK: omp.map.info | ||
! CHECK: omp.map.info | ||
! CHECK: omp.map.info | ||
|
||
! Verify that we load from the original/host allocation of the `upper_bound` | ||
! variable rather than the corresponding target region arg. | ||
|
||
! CHECK: fir.load %[[UB_ALLOC]] : !fir.ref<i32> | ||
! CHECK: omp.target | ||
|
||
! CHECK: } |