Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions flang/lib/Semantics/check-acc-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ void AccStructureChecker::CheckNotInComputeConstruct() {
}
}

bool AccStructureChecker::IsInsideParallelConstruct() const {
bool AccStructureChecker::IsInsideKernelsConstruct() const {
if (auto directive = getParentComputeConstruct())
if (*directive == llvm::acc::ACCD_parallel ||
*directive == llvm::acc::ACCD_parallel_loop)
if (*directive == llvm::acc::ACCD_kernels ||
*directive == llvm::acc::ACCD_kernels_loop)
return true;
return false;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
bool invalid{false};
if (parentClause == llvm::acc::Clause::ACCC_gang &&
cl == llvm::acc::Clause::ACCC_gang) {
if (IsInsideParallelConstruct()) {
if (!IsInsideKernelsConstruct()) {
auto parentDim = getGangDimensionSize(parent);
auto currentDim = getGangDimensionSize(GetContext());
std::int64_t parentDimNum = 1, currentDimNum = 1;
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/check-acc-structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class AccStructureChecker
bool IsLoopConstruct(llvm::acc::Directive directive) const;
std::optional<llvm::acc::Directive> getParentComputeConstruct() const;
bool IsInsideComputeConstruct() const;
bool IsInsideParallelConstruct() const;
bool IsInsideKernelsConstruct() const;
void CheckNotInComputeConstruct();
std::optional<std::int64_t> getGangDimensionSize(
DirectiveContext &dirContext);
Expand Down
31 changes: 31 additions & 0 deletions flang/test/Semantics/OpenACC/acc-loop.f90
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,35 @@ program openacc_loop_validity
END DO
END DO

contains

subroutine sub1()
!$acc routine gang(dim:2)
implicit none
integer, parameter :: N = 256
integer :: i, j

!$acc loop gang(dim:2)
DO j = 1, N
!$acc loop gang(dim:1) vector
DO i = 1, N
END DO
END DO
end subroutine sub1

subroutine sub2()
!$acc routine gang(dim:2)
implicit none
integer, parameter :: N = 256
integer :: i, j

!$acc loop gang(dim:2)
DO j = 1, N
!ERROR: GANG(dim:2) clause is not allowed in the region of a loop with the GANG(dim:2) clause
!$acc loop gang(dim:2) vector
DO i = 1, N
END DO
END DO
end subroutine sub2

end program openacc_loop_validity