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][cuda] Allow PINNED argument to host dummy #90651

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

clementval
Copy link
Contributor

Update the AreCompatibleCUDADataAttrs function to return true when one argument has the PINNED attribute and the other argument is just host data.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Apr 30, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 30, 2024

@llvm/pr-subscribers-flang-semantics

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

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 --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

@clementval clementval merged commit 89f8335 into llvm:main Apr 30, 2024
6 of 7 checks passed
@clementval clementval deleted the cuda_host_pinned_resolve branch April 30, 2024 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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