Skip to content

[flang][cuda] Do not emit warning for SHARED variable in device subprogram #115195

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
Nov 6, 2024

Conversation

clementval
Copy link
Contributor

SHARED attribute is explicitly meant to be used in device subprogram (https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#cfpg-var-qual-attr-shared).

Do not emit warning.

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

llvmbot commented Nov 6, 2024

@llvm/pr-subscribers-flang-semantics

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

Changes

SHARED attribute is explicitly meant to be used in device subprogram (https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#cfpg-var-qual-attr-shared).

Do not emit warning.


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

2 Files Affected:

  • (modified) flang/lib/Semantics/check-declarations.cpp (+3-1)
  • (modified) flang/test/Semantics/cuf03.cuf (+2-1)
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index f8e873008ceabc..86881225e1e55c 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -928,7 +928,9 @@ void CheckHelper::CheckObjectEntity(
         details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
             common::CUDADataAttr::Device &&
         details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
-            common::CUDADataAttr::Managed) {
+            common::CUDADataAttr::Managed &&
+        details.cudaDataAttr().value_or(common::CUDADataAttr::Device) !=
+            common::CUDADataAttr::Shared) {
       Warn(common::UsageWarning::CUDAUsage,
           "Dummy argument '%s' may not have ATTRIBUTES(%s) in a device subprogram"_warn_en_US,
           symbol.name(),
diff --git a/flang/test/Semantics/cuf03.cuf b/flang/test/Semantics/cuf03.cuf
index a98dd60cdb8a4e..93b136ad7d3157 100644
--- a/flang/test/Semantics/cuf03.cuf
+++ b/flang/test/Semantics/cuf03.cuf
@@ -55,13 +55,14 @@ module m
   real, unified :: um
 
  contains
-  attributes(device) subroutine devsubr(n,da)
+  attributes(device) subroutine devsubr(n,da,rs)
     integer, intent(in) :: n
     real, device :: da(*) ! ok
     real, managed :: ma(n) ! ok
     !WARNING: Pointer 'dp' may not be associated in a device subprogram
     real, device, pointer :: dp
     real, constant :: rc ! ok
+    real, shared :: rs ! ok
     !ERROR: Object 'u' with ATTRIBUTES(UNIFIED) must be declared in a host subprogram
     real, unified :: u
   end subroutine

@clementval clementval merged commit a878dc8 into llvm:main Nov 6, 2024
8 of 10 checks passed
@clementval clementval deleted the cuf_remove_warn_shared branch November 6, 2024 21:19
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