[flang][cuda] Take associate into account for host array diagnostic (#190673)
This commit is contained in:
parent
fbe6d79465
commit
92b595b9b4
@ -116,8 +116,9 @@ struct DeviceExprChecker
|
|||||||
};
|
};
|
||||||
|
|
||||||
static bool IsHostArray(const Symbol &symbol) {
|
static bool IsHostArray(const Symbol &symbol) {
|
||||||
|
const Symbol &resolved{GetAssociationRoot(symbol)};
|
||||||
if (const auto *details{
|
if (const auto *details{
|
||||||
symbol.GetUltimate().detailsIf<semantics::ObjectEntityDetails>()}) {
|
resolved.detailsIf<semantics::ObjectEntityDetails>()}) {
|
||||||
if (details->cudaDataAttr() &&
|
if (details->cudaDataAttr() &&
|
||||||
(*details->cudaDataAttr() == common::CUDADataAttr::Device ||
|
(*details->cudaDataAttr() == common::CUDADataAttr::Device ||
|
||||||
*details->cudaDataAttr() == common::CUDADataAttr::Constant ||
|
*details->cudaDataAttr() == common::CUDADataAttr::Constant ||
|
||||||
@ -137,8 +138,8 @@ struct FindHostArray
|
|||||||
FindHostArray() : Base(*this) {}
|
FindHostArray() : Base(*this) {}
|
||||||
using Base::operator();
|
using Base::operator();
|
||||||
Result operator()(const evaluate::Component &x) const {
|
Result operator()(const evaluate::Component &x) const {
|
||||||
const Symbol &symbol{x.GetLastSymbol()};
|
const Symbol &symbol{x.GetLastSymbol().GetUltimate()};
|
||||||
const Symbol &baseSymbol{x.base().GetFirstSymbol()};
|
const Symbol &baseSymbol{GetAssociationRoot(x.base().GetFirstSymbol())};
|
||||||
if (symbol.IsFuncResult() || baseSymbol.IsFuncResult()) {
|
if (symbol.IsFuncResult() || baseSymbol.IsFuncResult()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,3 +20,25 @@ contains
|
|||||||
r%origin = origin
|
r%origin = origin
|
||||||
end function
|
end function
|
||||||
end module m
|
end module m
|
||||||
|
|
||||||
|
program main
|
||||||
|
implicit none
|
||||||
|
integer, parameter :: nx = 400, ny = 200
|
||||||
|
integer :: i, j
|
||||||
|
type r1
|
||||||
|
real :: v(3)
|
||||||
|
end type r1
|
||||||
|
type(r1) :: fb(nx, ny)
|
||||||
|
type(r1), device :: fb_d(nx, ny)
|
||||||
|
|
||||||
|
associate (fb => fb_d)
|
||||||
|
!$cuf kernel do (2) <<<*,*>>>
|
||||||
|
do j = 1, ny
|
||||||
|
do i = 1, nx
|
||||||
|
fb(i,j)%v(1) = real(i)/nx
|
||||||
|
fb(i,j)%v(2) = real(j)/ny
|
||||||
|
fb(i,j)%v(3) = 0.2
|
||||||
|
end do
|
||||||
|
end do
|
||||||
|
end associate
|
||||||
|
end program
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user