[flang-commits] [flang] [flang][cuda] Do not lower PINNED variable in main program as global (PR #102996)

via flang-commits flang-commits at lists.llvm.org
Mon Aug 12 20:17:40 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

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

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

<details>
<summary>Changes</summary>

Similar to #<!-- -->102512. Do not lower PINNED variable descriptors in program unit as globals but keep them local. 

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


2 Files Affected:

- (modified) flang/include/flang/Evaluate/tools.h (-1) 
- (modified) flang/test/Lower/CUDA/cuda-program-global.cuf (+2) 


``````````diff
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index de4d415eda6fd6..3675d9f924876a 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -1247,7 +1247,6 @@ inline bool CanCUDASymbolHasSave(const Symbol &sym) {
   if (const auto *details =
           sym.GetUltimate().detailsIf<semantics::ObjectEntityDetails>()) {
     if (details->cudaDataAttr() &&
-        *details->cudaDataAttr() != common::CUDADataAttr::Pinned &&
         *details->cudaDataAttr() != common::CUDADataAttr::Unified) {
       return false;
     }
diff --git a/flang/test/Lower/CUDA/cuda-program-global.cuf b/flang/test/Lower/CUDA/cuda-program-global.cuf
index a3c9e1ba8d253c..90b401c9ba6a5c 100644
--- a/flang/test/Lower/CUDA/cuda-program-global.cuf
+++ b/flang/test/Lower/CUDA/cuda-program-global.cuf
@@ -6,6 +6,7 @@
 program test
   integer, device :: a(10)
   integer, unified :: u(10)
+  integer, allocatable, pinned :: p(:)
   integer :: b(10)
   integer :: i
   print*,i
@@ -16,6 +17,7 @@ end
 ! CHECK: fir.address_of(@_QFEb) : !fir.ref<!fir.array<10xi32>>
 ! CHECK: %[[ALLOCA:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFEi"}
 ! CHECK: hlfir.declare %[[ALLOCA]] {uniq_name = "_QFEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
+! CHECK: cuf.alloc !fir.box<!fir.heap<!fir.array<?xi32>>> {bindc_name = "p", data_attr = #cuf.cuda<pinned>, uniq_name = "_QFEp"} -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
 
 ! CHECK-NOT: fir.global internal @_QFEa {data_attr = #cuf.cuda<device>} : !fir.array<10xi32> {{{$}}
 ! CHECK: fir.global internal @_QFEb : !fir.array<10xi32> {{{$}}

``````````

</details>


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


More information about the flang-commits mailing list