Skip to content

[flang][OpenMP] Don't check unlabelled cycle branching for target loops #111656

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 1 commit into from
Oct 9, 2024

Conversation

ergawy
Copy link
Member

@ergawy ergawy commented Oct 9, 2024

Properly handles cycle branching inside target distribute loops.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp flang:semantics labels Oct 9, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2024

@llvm/pr-subscribers-flang-openmp

@llvm/pr-subscribers-flang-semantics

Author: Kareem Ergawy (ergawy)

Changes

Properly handles cycle branching inside target distribute loops.


Full diff: https://github.com/llvm/llvm-project/pull/111656.diff

2 Files Affected:

  • (modified) flang/lib/Semantics/check-directive-structure.h (+2)
  • (modified) flang/test/Semantics/OpenMP/do05-positivecase.f90 (+15)
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index a1aff52f3a6843..ee360161d351e6 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -74,6 +74,8 @@ template <typename D> class NoBranchingEnforce {
         case llvm::omp::Directive::OMPD_distribute_parallel_for:
         case llvm::omp::Directive::OMPD_distribute_simd:
         case llvm::omp::Directive::OMPD_distribute_parallel_for_simd:
+        case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do:
+        case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do_simd:
           return;
         default:
           break;
diff --git a/flang/test/Semantics/OpenMP/do05-positivecase.f90 b/flang/test/Semantics/OpenMP/do05-positivecase.f90
index 3b512a5b4f25eb..5e1b1b86f72f61 100644
--- a/flang/test/Semantics/OpenMP/do05-positivecase.f90
+++ b/flang/test/Semantics/OpenMP/do05-positivecase.f90
@@ -42,4 +42,19 @@ program omp_do
   end do
   !$omp end parallel
 
+  !$omp target teams distribute parallel do
+  !DEF:/omp_do/OtherConstruct4/i (OmpPrivate ,OmpPreDetermined) HostAssoc INTEGER(4)
+  do i=1,100
+    !REF:/omp_do/OtherConstruct4/i
+    if(i<10) cycle
+  end do
+  !$omp end target teams distribute parallel do
+
+  !$omp target teams distribute parallel do simd
+  !DEF:/omp_do/OtherConstruct5/i (OmpLinear,OmpPreDetermined) HostAssoc INTEGER(4)
+  do i=1,100
+    !REF:/omp_do/OtherConstruct5/i
+    if(i<10) cycle
+  end do
+  !$omp end target teams distribute parallel do simd
 end program omp_do

@ergawy ergawy requested review from mjklemm and kiranktp October 9, 2024 10:03
Copy link

github-actions bot commented Oct 9, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

…oops

Properly handles `cycle` branching inside target distribute loops.
Copy link
Contributor

@NimishMishra NimishMishra left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks

Copy link
Contributor

@mjklemm mjklemm left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -74,6 +74,9 @@ template <typename D> class NoBranchingEnforce {
case llvm::omp::Directive::OMPD_distribute_parallel_for:
case llvm::omp::Directive::OMPD_distribute_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_for_simd:
case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do:
case llvm::omp::Directive::
OMPD_target_teams_distribute_parallel_do_simd:
Copy link
Contributor

Choose a reason for hiding this comment

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

Stray formatting change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, our formatting rules demand this.

@ergawy ergawy merged commit c4d288d into llvm:main Oct 9, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:openmp flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants