-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[flang][OpenMP] Allow loop iteration variables in DSA clauses #86194
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
Conversation
Iteration variables of non-associated loops may be listed in DSA clauses. Fixes llvm#78938
@llvm/pr-subscribers-flang-semantics @llvm/pr-subscribers-flang-openmp Author: Leandro Lupori (luporl) ChangesIteration variables of non-associated loops may be listed in DSA Fixes #78938 Full diff: https://github.com/llvm/llvm-project/pull/86194.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 6d58013b87d298..95dea05d9a760d 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1649,6 +1649,12 @@ void OmpAttributeVisitor::ResolveSeqLoopIndexInParallelOrTaskConstruct(
break;
}
}
+ // If this symbol already has a data-sharing attribute then there is nothing
+ // to do here.
+ if (const Symbol *symbol = iv.symbol)
+ for (auto symMap : targetIt->objectWithDSA)
+ if (symMap.first->name() == symbol->name())
+ return;
// If this symbol is already Private or Firstprivate in the enclosing
// OpenMP parallel or task then there is nothing to do here.
if (auto *symbol{targetIt->scope.FindSymbol(iv.source)}) {
diff --git a/flang/test/Semantics/OpenMP/do20.f90 b/flang/test/Semantics/OpenMP/do20.f90
new file mode 100644
index 00000000000000..915d01e69edd74
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/do20.f90
@@ -0,0 +1,18 @@
+! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp
+
+! OpenMP 5.2 5.1.1
+! Iteration variables of non-associated loops may be listed in DSA clauses.
+
+!DEF: /shared_iv (Subroutine)Subprogram
+subroutine shared_iv
+ !DEF: /shared_iv/i ObjectEntity INTEGER(4)
+ integer i
+
+ !$omp parallel shared(i)
+ !$omp single
+ !REF: /shared_iv/i
+ do i = 0, 1
+ end do
+ !$omp end single
+ !$omp end parallel
+end subroutine
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please wait for @mjklemm
if (const Symbol *symbol = iv.symbol) | ||
for (auto symMap : targetIt->objectWithDSA) | ||
if (symMap.first->name() == symbol->name()) | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Frontend style uses curly braces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
✅ With the latest revision this PR passed the C/C++ code formatter. |
Thanks for the quick reviews! |
Iteration variables of non-associated loops may be listed in DSA
clauses.
Fixes #78938