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] Apply implicit data attribute only in device context #119919

Merged
merged 1 commit into from
Dec 13, 2024

Conversation

clementval
Copy link
Contributor

Fix the condition so the implicit device data attribute is not applied when the routine has attribute(host)

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Dec 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 13, 2024

@llvm/pr-subscribers-flang-semantics

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

Changes

Fix the condition so the implicit device data attribute is not applied when the routine has attribute(host)


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

2 Files Affected:

  • (modified) flang/lib/Semantics/resolve-names.cpp (+3-3)
  • (modified) flang/test/Semantics/modfile55.cuf (+7)
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index aef2898919f3ff..6a920cff83b51d 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -8958,9 +8958,9 @@ void ResolveNamesVisitor::FinishSpecificationPart(
               ? currScope().symbol()->detailsIf<SubprogramDetails>()
               : nullptr}) {
     if (auto attrs{subp->cudaSubprogramAttrs()}) {
-      if (*attrs != common::CUDASubprogramAttrs::Device ||
-          *attrs != common::CUDASubprogramAttrs::Global ||
-          *attrs != common::CUDASubprogramAttrs::Grid_Global) {
+      if (*attrs == common::CUDASubprogramAttrs::Device ||
+          *attrs == common::CUDASubprogramAttrs::Global ||
+          *attrs == common::CUDASubprogramAttrs::Grid_Global) {
         inDeviceSubprogram = true;
       }
     }
diff --git a/flang/test/Semantics/modfile55.cuf b/flang/test/Semantics/modfile55.cuf
index 6c0d152a382a88..90c384cbd55b9c 100644
--- a/flang/test/Semantics/modfile55.cuf
+++ b/flang/test/Semantics/modfile55.cuf
@@ -14,6 +14,10 @@ module m
   attributes(host,device) real function foo(x)
     foo = x + 1.
   end function
+  attributes(host) subroutine hostsub(a)
+    integer, intent(out) :: a(14)
+    a = 99
+  end subroutine
 end
 
 !Expect: m.mod
@@ -39,4 +43,7 @@ end
 !real(4)::x
 !real(4)::foo
 !end
+attributes(host)subroutinehostsub(a)
+integer(4),intent(out)::a(1_8:14_8)
+end
 !end

@clementval clementval merged commit 3273d0b into llvm:main Dec 13, 2024
11 checks passed
@clementval clementval deleted the cuf_implicit_fix branch December 13, 2024 21:43
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.

3 participants