Skip to content

Commit

Permalink
[flang][cuda] Allow constant actual argument for device dummy (llvm#1…
Browse files Browse the repository at this point in the history
…21845)

The reference compiler allows this use case. Note that writing to this
variable would result in CUDA error.
  • Loading branch information
clementval authored Jan 6, 2025
1 parent d0c00cf commit 3874c64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flang/lib/Common/Fortran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
if (*x == CUDADataAttr::Device) {
if ((y &&
(*y == CUDADataAttr::Managed || *y == CUDADataAttr::Unified ||
*y == CUDADataAttr::Shared)) ||
*y == CUDADataAttr::Shared ||
*y == CUDADataAttr::Constant)) ||
(!y && (isCudaUnified || isCudaManaged))) {
if (y && *y == CUDADataAttr::Shared && warning) {
*warning = "SHARED attribute ignored"s;
Expand Down
7 changes: 7 additions & 0 deletions flang/test/Semantics/cuf10.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
module m
real, device :: a(4,8)
real, managed, allocatable :: b(:,:)
integer, constant :: x = 1
contains
attributes(global) subroutine kernel(a,b,c,n,m)
integer, value :: n
Expand All @@ -23,4 +24,10 @@ module m
call devsub(c,4) ! not checked in OpenACC construct
end do
end
attributes(global) subroutine sub1(x)
integer :: x
end
subroutine sub2()
call sub1<<<1,1>>>(x) ! actual constant to device dummy
end
end

0 comments on commit 3874c64

Please sign in to comment.