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

via flang-commits flang-commits at lists.llvm.org
Mon Apr 8 13:13:18 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Valentin Clement (バレンタイン クレメン) (clementval)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/88034.diff


2 Files Affected:

- (modified) flang/include/flang/Semantics/tools.h (+10) 
- (modified) flang/lib/Lower/Allocatable.cpp (+3) 


``````````diff
diff --git a/flang/include/flang/Semantics/tools.h b/flang/include/flang/Semantics/tools.h
index f0eb82eebefa31..b982ffe7946b3a 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..ddde4a4730c3dc 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 (HasCUDAAttr(alloc.getSymbol()))
+      TODO(loc, "Allocation of variable with CUDA attributes");
+
     fir::MutableBoxValue boxAddr =
         genMutableBoxValue(converter, loc, alloc.getAllocObj());
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/88034


More information about the flang-commits mailing list