[flang-commits] [flang] [Flang][OpenMP] : Compilation error involving Cray pointers and data sharing attributes (PR #82481)

via flang-commits flang-commits at lists.llvm.org
Wed Feb 21 03:06:58 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics

@llvm/pr-subscribers-flang-openmp

Author: Kiran Kumar T P (kiranktp)

<details>
<summary>Changes</summary>

Issue description:
	When DEFAULT DSA is NONE, all data refs must be listed in one of the data sharing clause.
	But when a Cray pointer is listed in one of the data sharing clause, Cray pointee can be used in parallel region.
	This is valid as per standard.
	"Cray pointee's have the same data-sharing attribute as the storage with which their Cray pointers are associated."

Solution:
	Added a check to discard checking Cray pointee when DEFAULT DSA is NONE.

This patch has code changes and a test case.

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


2 Files Affected:

- (modified) flang/lib/Semantics/resolve-directives.cpp (+3-1) 
- (added) flang/test/Semantics/OpenMP/cray-pointer-usage.f90 (+17) 


``````````diff
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 4b6d083671bc92..fb336853ae0c2d 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1995,7 +1995,9 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
             // Exclude indices of sequential loops that are privatised in
             // the scope of the parallel region, and not in this scope.
             // TODO: check whether this should be caught in IsObjectWithDSA
-            !symbol->test(Symbol::Flag::OmpPrivate)) {
+            !symbol->test(Symbol::Flag::OmpPrivate) &&
+            // If the symbol is a CrayPointee, It cannot appear in DSA clause
+            !symbol->test(Symbol::Flag::CrayPointee)) {
           context_.Say(name.source,
               "The DEFAULT(NONE) clause requires that '%s' must be listed in "
               "a data-sharing attribute clause"_err_en_US,
diff --git a/flang/test/Semantics/OpenMP/cray-pointer-usage.f90 b/flang/test/Semantics/OpenMP/cray-pointer-usage.f90
new file mode 100644
index 00000000000000..5d3c7f085cc4d3
--- /dev/null
+++ b/flang/test/Semantics/OpenMP/cray-pointer-usage.f90
@@ -0,0 +1,17 @@
+!RUN: %python %S/../test_errors.py %s %flang -fopenmp
+subroutine test_crayptr
+  implicit none
+  integer :: I
+  real*8 var(*)
+  pointer(ivar,var)
+  real*8 pointee(8)
+
+  pointee(1) = 42.0
+  ivar = loc(pointee)
+
+  !$omp parallel num_threads(2) default(none) shared(ivar)
+    print *, var(1)
+  !$omp end parallel
+
+end subroutine test_crayptr
+

``````````

</details>


https://github.com/llvm/llvm-project/pull/82481


More information about the flang-commits mailing list