[flang][cuda] Implicitly load cudadevice in host,device and grid_global procedures (#134905)

This commit is contained in:
Valentin Clement (バレンタイン クレメン)
2025-04-08 12:54:48 -07:00
committed by GitHub
parent 6f92339d9e
commit c4b343aeeb
2 changed files with 15 additions and 1 deletions

View File

@@ -4343,7 +4343,9 @@ bool SubprogramVisitor::Pre(const parser::PrefixSpec::Attributes &attrs) {
}
if (auto attrs{subp->cudaSubprogramAttrs()}) {
if (*attrs == common::CUDASubprogramAttrs::Global ||
*attrs == common::CUDASubprogramAttrs::Device) {
*attrs == common::CUDASubprogramAttrs::Grid_Global ||
*attrs == common::CUDASubprogramAttrs::Device ||
*attrs == common::CUDASubprogramAttrs::HostDevice) {
const Scope &scope{currScope()};
const Scope *mod{FindModuleContaining(scope)};
if (mod &&

View File

@@ -13,5 +13,17 @@ contains
!ERROR: 'threadfence' is use-associated from module 'cudadevice' and cannot be re-declared
integer :: threadfence
end subroutine
attributes(host,device) subroutine sub3()
if (on_device()) then
print*, 'on device'
else
print*, 'on host'
end if
end subroutine
attributes(grid_global) subroutine sub4()
call threadfence()
end subroutine
end module