[flang-commits] [flang] 89f8335 - [flang][cuda] Allow PINNED argument to host dummy (#90651)
via flang-commits
flang-commits at lists.llvm.org
Tue Apr 30 14:53:49 PDT 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-30T14:53:45-07:00
New Revision: 89f833588e573b6b9762bb4eca5b08a5d7bad9c5
URL: https://github.com/llvm/llvm-project/commit/89f833588e573b6b9762bb4eca5b08a5d7bad9c5
DIFF: https://github.com/llvm/llvm-project/commit/89f833588e573b6b9762bb4eca5b08a5d7bad9c5.diff
LOG: [flang][cuda] Allow PINNED argument to host dummy (#90651)
Update the `AreCompatibleCUDADataAttrs` function to return true when one
argument has the `PINNED` attribute and the other argument is just host
data.
Added:
flang/test/Semantics/cuf13.cuf
Modified:
flang/lib/Common/Fortran.cpp
Removed:
################################################################################
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
More information about the flang-commits
mailing list