[flang][cuda] Implicitly load cudadevice in host,device and grid_global procedures (#134905)
This commit is contained in:
committed by
GitHub
parent
6f92339d9e
commit
c4b343aeeb
@@ -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 &&
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user