Skip to content

Commit 81333cf

Browse files
authored
[flang][cuda] Relax host array check for cuda constant (#120333)
Array with CONSTANT attribute declared in module spec part are device arrays and should not trigger the host array check.
1 parent d7fe2cf commit 81333cf

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

flang/lib/Semantics/check-cuda.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ struct FindHostArray
114114
(!details->cudaDataAttr() ||
115115
(details->cudaDataAttr() &&
116116
*details->cudaDataAttr() != common::CUDADataAttr::Device &&
117+
*details->cudaDataAttr() != common::CUDADataAttr::Constant &&
117118
*details->cudaDataAttr() != common::CUDADataAttr::Managed &&
118119
*details->cudaDataAttr() != common::CUDADataAttr::Shared &&
119120
*details->cudaDataAttr() != common::CUDADataAttr::Unified))) {

flang/test/Semantics/cuf09.cuf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
! RUN: %python %S/test_errors.py %s %flang_fc1
22
module m
33
integer :: m(100)
4+
integer, constant :: c(10)
45
integer, parameter :: p(5) = [1,2,3,4,5]
56
contains
67
attributes(device) subroutine devsub
@@ -42,6 +43,12 @@ module m
4243
i = threadIdx%x
4344
a(i) = s(10) ! ok, a is device and s is shared
4445
end subroutine
46+
47+
attributes(global) subroutine cstarray(a)
48+
integer, device :: a(10)
49+
i = threadIdx%x
50+
a(i) = c(10) ! ok, a is device and c is constant
51+
end subroutine
4552
end
4653

4754
program main

0 commit comments

Comments
 (0)