Skip to content

Commit

Permalink
[flang][cuda] Relax host array check for cuda constant (llvm#120333)
Browse files Browse the repository at this point in the history
Array with CONSTANT attribute declared in module spec part are device
arrays and should not trigger the host array check.
  • Loading branch information
clementval authored Dec 18, 2024
1 parent d7fe2cf commit 81333cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions flang/lib/Semantics/check-cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct FindHostArray
(!details->cudaDataAttr() ||
(details->cudaDataAttr() &&
*details->cudaDataAttr() != common::CUDADataAttr::Device &&
*details->cudaDataAttr() != common::CUDADataAttr::Constant &&
*details->cudaDataAttr() != common::CUDADataAttr::Managed &&
*details->cudaDataAttr() != common::CUDADataAttr::Shared &&
*details->cudaDataAttr() != common::CUDADataAttr::Unified))) {
Expand Down
7 changes: 7 additions & 0 deletions flang/test/Semantics/cuf09.cuf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
module m
integer :: m(100)
integer, constant :: c(10)
integer, parameter :: p(5) = [1,2,3,4,5]
contains
attributes(device) subroutine devsub
Expand Down Expand Up @@ -42,6 +43,12 @@ module m
i = threadIdx%x
a(i) = s(10) ! ok, a is device and s is shared
end subroutine

attributes(global) subroutine cstarray(a)
integer, device :: a(10)
i = threadIdx%x
a(i) = c(10) ! ok, a is device and c is constant
end subroutine
end

program main
Expand Down

0 comments on commit 81333cf

Please sign in to comment.