[flang-commits] [flang] [flang][cuda] Disable host array check when unified is enabled (PR #191054)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Wed Apr 8 14:17:38 PDT 2026


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

None

>From c7438db449811c8331f110764f66bec9328d2f18 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Wed, 8 Apr 2026 14:16:55 -0700
Subject: [PATCH] [flang][cuda] Disable host array check when unified is
 enabled

---
 flang/lib/Semantics/check-cuda.cpp     |  3 +++
 flang/test/Lower/CUDA/cuda-unified.cuf | 12 ++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 flang/test/Lower/CUDA/cuda-unified.cuf

diff --git a/flang/lib/Semantics/check-cuda.cpp b/flang/lib/Semantics/check-cuda.cpp
index fcfbf29972ca9..62ece9e57b5d6 100644
--- a/flang/lib/Semantics/check-cuda.cpp
+++ b/flang/lib/Semantics/check-cuda.cpp
@@ -439,6 +439,9 @@ template <bool IsCUFKernelDo> class DeviceContextChecker {
   void ErrorIfHostSymbol(const A &expr, parser::CharBlock source) {
     if (isHostDevice)
       return;
+    if (context_.languageFeatures().IsEnabled(
+            common::LanguageFeature::CudaUnified))
+      return;
     if (const Symbol * hostArray{FindHostArray{}(expr)}) {
       context_.Say(source,
           "Host array '%s' cannot be present in device context"_err_en_US,
diff --git a/flang/test/Lower/CUDA/cuda-unified.cuf b/flang/test/Lower/CUDA/cuda-unified.cuf
new file mode 100644
index 0000000000000..167f35e3beba2
--- /dev/null
+++ b/flang/test/Lower/CUDA/cuda-unified.cuf
@@ -0,0 +1,12 @@
+! RUN: bbc -emit-hlfir -fcuda -gpu=unified %s -o - | FileCheck %s
+
+program t
+real :: a(10000)
+!$cuf kernel do(1) <<<100,100>>>
+do concurrent (i = 1:10000)
+  a(i) = a(i) + 1.0
+end do
+print *,sum(a)
+end
+
+! CHECK: cuf.kernel



More information about the flang-commits mailing list