Skip to content

Commit 89f8335

Browse files
authored
[flang][cuda] Allow PINNED argument to host dummy (#90651)
Update the `AreCompatibleCUDADataAttrs` function to return true when one argument has the `PINNED` attribute and the other argument is just host data.
1 parent fb85a28 commit 89f8335

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

flang/lib/Common/Fortran.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
103103
return true;
104104
} else if (x && y && *x == *y) {
105105
return true;
106+
} else if ((!x && y && *y == CUDADataAttr::Pinned) ||
107+
(x && *x == CUDADataAttr::Pinned && !y)) {
108+
return true;
106109
} else if (ignoreTKR.test(IgnoreTKR::Device) &&
107110
x.value_or(CUDADataAttr::Device) == CUDADataAttr::Device &&
108111
y.value_or(CUDADataAttr::Device) == CUDADataAttr::Device) {

flang/test/Semantics/cuf13.cuf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
! RUN: %python %S/test_errors.py %s %flang_fc1
2+
3+
module matching
4+
interface sub
5+
module procedure sub_host
6+
module procedure sub_device
7+
end interface
8+
9+
contains
10+
subroutine sub_host(a)
11+
integer :: a(:)
12+
end
13+
14+
subroutine sub_device(a)
15+
integer, device :: a(:)
16+
end
17+
18+
end module
19+
20+
program m
21+
use matching
22+
23+
integer, pinned, allocatable :: a(:)
24+
logical :: plog
25+
allocate(a(100), pinned = plog)
26+
27+
call sub(a)
28+
end

0 commit comments

Comments
 (0)