Skip to content

Commit f17e4f3

Browse files
committed
[flang][cuda] Allow host array with PARAMETER attribute in device context
1 parent 2a92290 commit f17e4f3

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
@@ -110,6 +110,7 @@ struct FindHostArray
110110
if (const auto *details{
111111
symbol.GetUltimate().detailsIf<semantics::ObjectEntityDetails>()}) {
112112
if (details->IsArray() &&
113+
!symbol.attrs().test(Fortran::semantics::Attr::PARAMETER) &&
113114
(!details->cudaDataAttr() ||
114115
(details->cudaDataAttr() &&
115116
*details->cudaDataAttr() != common::CUDADataAttr::Device &&

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, parameter :: p(5) = [1,2,3,4,5]
45
contains
56
attributes(device) subroutine devsub
67
!ERROR: Statement may not appear in device code
@@ -22,6 +23,12 @@ module m
2223
!ERROR: Host array 'm' cannot be present in device context
2324
if (i .le. N) a(i) = m(i)
2425
end subroutine
26+
27+
attributes(global) subroutine hostparameter(a)
28+
integer :: a(*)
29+
i = threadIdx%x
30+
if (i .le. N) a(i) = p(i) ! ok. p is parameter
31+
end subroutine
2532
end
2633

2734
program main

0 commit comments

Comments
 (0)