Skip to content

[flang][openacc] Do not check for unlabelled CYCLE branching #73839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 18 additions & 14 deletions flang/lib/Semantics/check-directive-structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,24 @@ template <typename D> class NoBranchingEnforce {
if (const auto &cycleName{cycleStmt.v}) {
CheckConstructNameBranching("CYCLE", cycleName.value());
} else {
switch ((llvm::omp::Directive)currentDirective_) {
// exclude directives which do not need a check for unlabelled CYCLES
case llvm::omp::Directive::OMPD_do:
case llvm::omp::Directive::OMPD_simd:
case llvm::omp::Directive::OMPD_parallel_do:
case llvm::omp::Directive::OMPD_parallel_do_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_do:
case llvm::omp::Directive::OMPD_distribute_parallel_do_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_for:
case llvm::omp::Directive::OMPD_distribute_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_for_simd:
return;
default:
break;
if constexpr (std::is_same_v<D, llvm::omp::Directive>) {
switch ((llvm::omp::Directive)currentDirective_) {
// exclude directives which do not need a check for unlabelled CYCLES
case llvm::omp::Directive::OMPD_do:
case llvm::omp::Directive::OMPD_simd:
case llvm::omp::Directive::OMPD_parallel_do:
case llvm::omp::Directive::OMPD_parallel_do_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_do:
case llvm::omp::Directive::OMPD_distribute_parallel_do_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_for:
case llvm::omp::Directive::OMPD_distribute_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_for_simd:
return;
default:
break;
}
} else if constexpr (std::is_same_v<D, llvm::acc::Directive>) {
return; // OpenACC construct do not need check for unlabelled CYCLES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we will still report an error for this:

subroutine test
  do i=1,100
     !$acc data
     if (i == 10) cycle
     !$acc end data
  end do
end subroutine test

Or will it be handled elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We are not catching this anymore. Let me send another patch since this one was merge. I'll add a whitelist of construct to skip like it is done for OpenMP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
CheckConstructNameBranching("CYCLE");
}
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Semantics/OpenACC/acc-kernels-loop.f90
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,9 @@ program openacc_kernels_loop_validity
a(i) = 3.14
end do

!$acc parallel loop
do i = 1, N
if(i == 10) cycle
end do

end program openacc_kernels_loop_validity
7 changes: 7 additions & 0 deletions flang/test/Semantics/OpenACC/acc-loop.f90
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,11 @@ program openacc_loop_validity
end do
end do

!$acc parallel
!$acc loop
do i = 1, n
if(i == 10) cycle
end do
!$acc end parallel

end program openacc_loop_validity
5 changes: 5 additions & 0 deletions flang/test/Semantics/OpenACC/acc-parallel-loop-validity.f90
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,9 @@ program openacc_parallel_loop_validity
reduction_l = d(i) .neqv. e(i)
end do

!$acc parallel loop
do i = 1, N
if(i == 10) cycle
end do

end program openacc_parallel_loop_validity
5 changes: 5 additions & 0 deletions flang/test/Semantics/OpenACC/acc-serial-loop.f90
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ program openacc_serial_loop_validity
end do
!$acc end serial

!$acc serial loop
do i = 1, n
if(i == 10) cycle
end do

end program openacc_serial_loop_validity