[flang-commits] [flang] b1a278d - [flang][cuda] Add a proper TODO for allocate statement for cuda var (#88034)

via flang-commits flang-commits at lists.llvm.org
Tue Apr 9 09:44:59 PDT 2024


Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-04-09T09:44:55-07:00
New Revision: b1a278dd874d6135780fc824c6aa263c52d7aadd

URL: https://github.com/llvm/llvm-project/commit/b1a278dd874d6135780fc824c6aa263c52d7aadd
DIFF: https://github.com/llvm/llvm-project/commit/b1a278dd874d6135780fc824c6aa263c52d7aadd.diff

LOG: [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.

Added: 
    

Modified: 
    flang/include/flang/Semantics/tools.h
    flang/lib/Lower/Allocatable.cpp

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index f0eb82eebefa31..da10969ebc7021 100644
--- a/flang/include/flang/Semantics/tools.h
+++ b/flang/include/flang/Semantics/tools.h
@@ -212,6 +212,16 @@ inline bool IsCUDADeviceContext(const Scope *scope) {
   return false;
 }
 
+inline bool HasCUDAAttr(const Symbol &sym) {
+  if (const auto *details{
+          sym.GetUltimate().detailsIf<semantics::ObjectEntityDetails>()}) {
+    if (details->cudaDataAttr()) {
+      return true;
+    }
+  }
+  return false;
+}
+
 const Scope *FindCUDADeviceContext(const Scope *);
 std::optional<common::CUDADataAttr> GetCUDADataAttr(const Symbol *);
 

diff  --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 09180518ea41d9..42e78fc96e4445 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -379,6 +379,9 @@ class AllocateStmtHelper {
   }
 
   void lowerAllocation(const Allocation &alloc) {
+    if (Fortran::semantics::HasCUDAAttr(alloc.getSymbol()))
+      TODO(loc, "Allocation of variable with CUDA attributes");
+
     fir::MutableBoxValue boxAddr =
         genMutableBoxValue(converter, loc, alloc.getAllocObj());
 


        


More information about the flang-commits mailing list