Skip to content

Commit

Permalink
[flang][cuda] Allow PINNED argument to host dummy (llvm#90651)
Browse files Browse the repository at this point in the history
Update the `AreCompatibleCUDADataAttrs` function to return true when one
argument has the `PINNED` attribute and the other argument is just host
data.
  • Loading branch information
clementval authored Apr 30, 2024
1 parent fb85a28 commit 89f8335
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flang/lib/Common/Fortran.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
return true;
} else if (x && y && *x == *y) {
return true;
} else if ((!x && y && *y == CUDADataAttr::Pinned) ||
(x && *x == CUDADataAttr::Pinned && !y)) {
return true;
} else if (ignoreTKR.test(IgnoreTKR::Device) &&
x.value_or(CUDADataAttr::Device) == CUDADataAttr::Device &&
y.value_or(CUDADataAttr::Device) == CUDADataAttr::Device) {
Expand Down
28 changes: 28 additions & 0 deletions flang/test/Semantics/cuf13.cuf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
! RUN: %python %S/test_errors.py %s %flang_fc1

module matching
interface sub
module procedure sub_host
module procedure sub_device
end interface

contains
subroutine sub_host(a)
integer :: a(:)
end

subroutine sub_device(a)
integer, device :: a(:)
end

end module

program m
use matching

integer, pinned, allocatable :: a(:)
logical :: plog
allocate(a(100), pinned = plog)

call sub(a)
end

0 comments on commit 89f8335

Please sign in to comment.