Skip to content

Commit b353b0b

Browse files
committed
[flang][OpenMP] Support bind clause for teams loop
Extends generic `loop` directive support by supporting the `bind` clause. Since semantic checking does the heavy lifting of verifying the proper usage of the clause modifier, we can simply enable code-gen for `teams loop bind(...)` without the need to differentiate between the values the the clause can accept.
1 parent 9456e7f commit b353b0b

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ class GenericLoopConversionPattern
8484
<< loopOp->getName() << " operation";
8585
};
8686

87-
// For standalone directives, `bind` is already supported. Other combined
88-
// forms will be supported in a follow-up PR.
89-
if (combinedInfo != GenericLoopCombinedInfo::Standalone &&
87+
// For `loop` and `teams loop` directives, `bind` is supported.
88+
// Additionally, for `teams loop`, semantic checking verifies that the
89+
// `bind` clause modifier is `teams`, so no need to check this here again.
90+
if (combinedInfo == GenericLoopCombinedInfo::ParallelLoop &&
9091
loopOp.getBindKind())
9192
return todo("bind");
9293

flang/test/Lower/OpenMP/generic-loop-rewriting.f90

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
1+
!RUN: split-file %s %t
22

3+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %t/no_bind_clause.f90 -o - \
4+
!RUN: | FileCheck %s
5+
6+
!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 %t/bind_clause_teams.f90 -o - \
7+
!RUN: | FileCheck %s
8+
9+
!--- no_bind_clause.f90
310
subroutine target_teams_loop
411
implicit none
512
integer :: x, i
@@ -10,6 +17,17 @@ subroutine target_teams_loop
1017
end do
1118
end subroutine target_teams_loop
1219

20+
!--- bind_clause_teams.f90
21+
subroutine target_teams_loop
22+
implicit none
23+
integer :: x, i
24+
25+
!$omp target teams loop bind(teams)
26+
do i = 0, 10
27+
x = x + i
28+
end do
29+
end subroutine target_teams_loop
30+
1331
!CHECK-LABEL: func.func @_QPtarget_teams_loop
1432
!CHECK: omp.target map_entries(
1533
!CHECK-SAME: %{{.*}} -> %[[I_ARG:[^[:space:]]+]],

0 commit comments

Comments
 (0)