Skip to content
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

[flang][OpenMP] Accept firstprivate vars in copyprivate #80467

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

luporl
Copy link
Contributor

@luporl luporl commented Feb 2, 2024

This is patch 1 of 4, to add support for COPYPRIVATE.
Original PR: #73128

This is patch 1 of 4, to add support for COPYPRIVATE.
Original PR: llvm#73128
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp flang:semantics labels Feb 2, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 2, 2024

@llvm/pr-subscribers-flang-semantics

@llvm/pr-subscribers-flang-openmp

Author: Leandro Lupori (luporl)

Changes

This is patch 1 of 4, to add support for COPYPRIVATE.
Original PR: #73128


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

2 Files Affected:

  • (modified) flang/lib/Semantics/resolve-directives.cpp (+2-1)
  • (modified) flang/test/Semantics/OpenMP/copyprivate03.f90 (+7)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 2c570bc3abeb2..ef5a01c1ca821 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2429,7 +2429,8 @@ void OmpAttributeVisitor::CheckDataCopyingClause(
       // either 'private' or 'threadprivate' in enclosing context.
       if (!checkSymbol->test(Symbol::Flag::OmpThreadprivate) &&
           !(HasSymbolInEnclosingScope(symbol, currScope()) &&
-              symbol.test(Symbol::Flag::OmpPrivate))) {
+              (symbol.test(Symbol::Flag::OmpPrivate) ||
+                  symbol.test(Symbol::Flag::OmpFirstPrivate)))) {
         context_.Say(name.source,
             "COPYPRIVATE variable '%s' is not PRIVATE or THREADPRIVATE in "
             "outer context"_err_en_US,
diff --git a/flang/test/Semantics/OpenMP/copyprivate03.f90 b/flang/test/Semantics/OpenMP/copyprivate03.f90
index eccc308b1d5ab..9d39fdb6b13c8 100644
--- a/flang/test/Semantics/OpenMP/copyprivate03.f90
+++ b/flang/test/Semantics/OpenMP/copyprivate03.f90
@@ -34,6 +34,13 @@ program omp_copyprivate
   !$omp end parallel
   !$omp end parallel sections
 
+  !The use of FIRSTPRIVATE with COPYPRIVATE is allowed
+  !$omp parallel firstprivate(a)
+  !$omp single
+  a = a + k
+  !$omp end single copyprivate(a)
+  !$omp end parallel
+
   print *, a, b
 
 end program omp_copyprivate

Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

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

LG.

@luporl luporl merged commit e686695 into llvm:main Feb 6, 2024
7 checks passed
@luporl luporl deleted the luporl-copypriv-sema branch February 6, 2024 13:02
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.

None yet

3 participants