Skip to content

Commit b1a278d

Browse files
authored
[flang][cuda] Add a proper TODO for allocate statement for cuda var (#88034)
Allocate statement for variable with CUDA attributes need to allocate memory on the device and not the host. Add a proper TODO so we keep track of work to be done for it.
1 parent bab0507 commit b1a278d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

flang/include/flang/Semantics/tools.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ inline bool IsCUDADeviceContext(const Scope *scope) {
212212
return false;
213213
}
214214

215+
inline bool HasCUDAAttr(const Symbol &sym) {
216+
if (const auto *details{
217+
sym.GetUltimate().detailsIf<semantics::ObjectEntityDetails>()}) {
218+
if (details->cudaDataAttr()) {
219+
return true;
220+
}
221+
}
222+
return false;
223+
}
224+
215225
const Scope *FindCUDADeviceContext(const Scope *);
216226
std::optional<common::CUDADataAttr> GetCUDADataAttr(const Symbol *);
217227

flang/lib/Lower/Allocatable.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ class AllocateStmtHelper {
379379
}
380380

381381
void lowerAllocation(const Allocation &alloc) {
382+
if (Fortran::semantics::HasCUDAAttr(alloc.getSymbol()))
383+
TODO(loc, "Allocation of variable with CUDA attributes");
384+
382385
fir::MutableBoxValue boxAddr =
383386
genMutableBoxValue(converter, loc, alloc.getAllocObj());
384387

0 commit comments

Comments
 (0)