Skip to content

Commit b1161b2

Browse files
authored
[Flang][OpenMP] Fix semantics check for nested DISTRIBUTE (#91592)
Composite OpenMP constructs where DISTRIBUTE is the first leaf construct, as well as standalone DISTRIBUTE constructs, are allowed inside of TEAMS regions. Before this patch, nesting a DISTRIBUTE construct inside of a combined TARGET TEAMS construct was disallowed, which it shouldn't be. Now both TEAMS and TARGET TEAMS constructs can be immediate parents of DISTRIBUTE constructs.
1 parent f39af73 commit b1161b2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ void OmpStructureChecker::HasInvalidDistributeNesting(
280280
violation = true;
281281
} else {
282282
// `distribute` region has to be strictly nested inside `teams`
283-
if (!llvm::omp::topTeamsSet.test(GetContextParent().directive)) {
283+
if (!OmpDirectiveSet{llvm::omp::OMPD_teams, llvm::omp::OMPD_target_teams}
284+
.test(GetContextParent().directive)) {
284285
violation = true;
285286
}
286287
}

flang/test/Semantics/OpenMP/nested-distribute.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ program main
7474
!$omp end distribute
7575
!$omp end teams
7676

77+
!$omp target teams
78+
!$omp distribute
79+
do i = 1, 10
80+
end do
81+
!$omp end distribute
82+
!$omp end target teams
83+
7784
!$omp teams
7885
!ERROR: Only `DISTRIBUTE` or `PARALLEL` regions are allowed to be strictly nested inside `TEAMS` region.
7986
!$omp task

0 commit comments

Comments
 (0)