[flang-commits] [flang] [flang][cuda] Allow PINNED argument to host dummy (PR #90651)
via flang-commits
flang-commits at lists.llvm.org
Tue Apr 30 12:24:43 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
Update the `AreCompatibleCUDADataAttrs` function to return true when one argument has the `PINNED` attribute and the other argument is just host data.
---
Full diff: https://github.com/llvm/llvm-project/pull/90651.diff
2 Files Affected:
- (modified) flang/lib/Common/Fortran.cpp (+3)
- (added) flang/test/Semantics/cuf13.cuf (+28)
``````````diff
diff --git a/flang/lib/Common/Fortran.cpp b/flang/lib/Common/Fortran.cpp
index 27ff31ef78da28..8ada8fe210a30f 100644
--- a/flang/lib/Common/Fortran.cpp
+++ b/flang/lib/Common/Fortran.cpp
@@ -103,6 +103,9 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
return true;
} else if (x && y && *x == *y) {
return true;
+ } else if ((!x && y && *y == CUDADataAttr::Pinned) ||
+ (x && *x == CUDADataAttr::Pinned && !y)) {
+ return true;
} else if (ignoreTKR.test(IgnoreTKR::Device) &&
x.value_or(CUDADataAttr::Device) == CUDADataAttr::Device &&
y.value_or(CUDADataAttr::Device) == CUDADataAttr::Device) {
diff --git a/flang/test/Semantics/cuf13.cuf b/flang/test/Semantics/cuf13.cuf
new file mode 100644
index 00000000000000..7c6673e21bf11b
--- /dev/null
+++ b/flang/test/Semantics/cuf13.cuf
@@ -0,0 +1,28 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+
+module matching
+ interface sub
+ module procedure sub_host
+ module procedure sub_device
+ end interface
+
+contains
+ subroutine sub_host(a)
+ integer :: a(:)
+ end
+
+ subroutine sub_device(a)
+ integer, device :: a(:)
+ end
+
+end module
+
+program m
+ use matching
+
+ integer, pinned, allocatable :: a(:)
+ logical :: plog
+ allocate(a(100), pinned = plog)
+
+ call sub(a)
+end
``````````
</details>
https://github.com/llvm/llvm-project/pull/90651
More information about the flang-commits
mailing list