-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][cuda] Fix CUDA generic resolution for VALUE arguments in device procedures #140952
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
Conversation
@llvm/pr-subscribers-flang-semantics Author: Zhen Wang (wangzpgi) ChangesFor variables that have VALUE attribute inside device routines, implicitly set DEVICE attribute. Full diff: https://github.com/llvm/llvm-project/pull/140952.diff 3 Files Affected:
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 3f4a06444c4f3..f7c6a948375e4 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -9375,8 +9375,7 @@ void ResolveNamesVisitor::CreateGeneric(const parser::GenericSpec &x) {
static void SetImplicitCUDADevice(bool inDeviceSubprogram, Symbol &symbol) {
if (inDeviceSubprogram && symbol.has<ObjectEntityDetails>()) {
auto *object{symbol.detailsIf<ObjectEntityDetails>()};
- if (!object->cudaDataAttr() && !IsValue(symbol) &&
- !IsFunctionResult(symbol)) {
+ if (!object->cudaDataAttr() && !IsFunctionResult(symbol)) {
// Implicitly set device attribute if none is set in device context.
object->set_cudaDataAttr(common::CUDADataAttr::Device);
}
diff --git a/flang/test/Semantics/cuf21.cuf b/flang/test/Semantics/cuf21.cuf
index b8b99a8d1d9be..4251493c52e65 100644
--- a/flang/test/Semantics/cuf21.cuf
+++ b/flang/test/Semantics/cuf21.cuf
@@ -1,5 +1,6 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
-! Test generic matching with scalars argument without device attr
+! Test generic matching with scalars argument and argument
+! with VALUE attribute without DEVICE attr inside device routine
module mlocModule
interface maxlocUpdate
@@ -9,19 +10,22 @@ module mlocModule
end interface maxlocUpdate
contains
- attributes(global) subroutine maxlocPartialMaskR_32F1D()
+ attributes(global) subroutine maxlocPartialMaskR_32F1D(back)
implicit none
+ logical, intent(in), value :: back
real(4) :: mval
- call maxlocUpdate(mval)
+ call maxlocUpdate(mval, back)
end subroutine maxlocPartialMaskR_32F1D
- attributes(device) subroutine maxlocUpdateR_32F(mval)
+ attributes(device) subroutine maxlocUpdateR_32F(mval, back)
real(4) :: mval
+ logical :: back
end subroutine maxlocUpdateR_32F
- attributes(device) subroutine maxlocUpdateR_64F(mval)
+ attributes(device) subroutine maxlocUpdateR_64F(mval, back)
real(8) :: mval
+ logical :: back
end subroutine maxlocUpdateR_64F
end module
diff --git a/flang/test/Semantics/modfile55.cuf b/flang/test/Semantics/modfile55.cuf
index 2338b745d8355..abe6c30fa0f67 100644
--- a/flang/test/Semantics/modfile55.cuf
+++ b/flang/test/Semantics/modfile55.cuf
@@ -33,6 +33,7 @@ end
!contains
!attributes(global) subroutine globsub(x,y,z)
!real(4),value::x
+!attributes(device)x
!real(4)::y
!attributes(device) y
!real(4)::z
|
Should we close this or does it still makes sense? |
Let me evaluate, and I will probably end up with closing this one. Thanks for the reminder. |
I have updated this PR with an alternate fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ce procedures (llvm#140952) For actual arguments that have VALUE attribute inside device routines, treat them as if they have device attribute.
…ce procedures (llvm#140952) For actual arguments that have VALUE attribute inside device routines, treat them as if they have device attribute.
…ce procedures (llvm#140952) For actual arguments that have VALUE attribute inside device routines, treat them as if they have device attribute.
For variables that have VALUE attribute inside device routines, implicitly set DEVICE attribute.