Skip to content

[flang][cuda] Do not consider SHARED array as host array #120306

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

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

clementval
Copy link
Contributor

Update the current FindHostArray to not return shared array as host array.

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

llvmbot commented Dec 17, 2024

@llvm/pr-subscribers-flang-semantics

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

Changes

Update the current FindHostArray to not return shared array as host array.


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

2 Files Affected:

  • (modified) flang/lib/Semantics/check-cuda.cpp (+1)
  • (modified) flang/test/Semantics/cuf09.cuf (+7)
diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index 9c044a47c79834..7e458d3b55a89c 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -114,6 +114,7 @@ struct FindHostArray
               (details->cudaDataAttr() &&
                   *details->cudaDataAttr() != common::CUDADataAttr::Device &&
                   *details->cudaDataAttr() != common::CUDADataAttr::Managed &&
+                  *details->cudaDataAttr() != common::CUDADataAttr::Shared &&
                   *details->cudaDataAttr() != common::CUDADataAttr::Unified))) {
         return &symbol;
       }
diff --git a/flang/test/Semantics/cuf09.cuf b/flang/test/Semantics/cuf09.cuf
index e0ca814aec26a0..3a9efecbdb60b7 100644
--- a/flang/test/Semantics/cuf09.cuf
+++ b/flang/test/Semantics/cuf09.cuf
@@ -28,6 +28,13 @@ module m
     i = threadIdx%x
     a(i) = i
   end subroutine
+
+  attributes(global) subroutine sharedarray(a)
+    integer, device :: a(10)
+    integer, shared :: s(10)
+    i = threadIdx%x
+    a(i) = s(10) ! ok, a is device and s is shared
+  end subroutine
 end
 
 program main

@clementval clementval merged commit 15c61a2 into llvm:main Dec 17, 2024
8 of 9 checks passed
@clementval clementval deleted the cuf_sema_shared_array branch December 17, 2024 21:42
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