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

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Mon Aug 12 20:17:08 PDT 2024


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

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

>From 4030c5415781fe7dea3a3e47871e1245c7264295 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Mon, 12 Aug 2024 20:15:27 -0700
Subject: [PATCH] [flang][cuda] Do not lower PINNED variable in main program as
 global

---
 flang/include/flang/Evaluate/tools.h          | 1 -
 flang/test/Lower/CUDA/cuda-program-global.cuf | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

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> {{{$}}



More information about the flang-commits mailing list