[flang-commits] [flang] [flang][cuda] Disable host array check when unified is enabled (PR #191054)
via flang-commits
flang-commits at lists.llvm.org
Wed Apr 8 14:18:14 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/191054.diff
2 Files Affected:
- (modified) flang/lib/Semantics/check-cuda.cpp (+3)
- (added) flang/test/Lower/CUDA/cuda-unified.cuf (+12)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/191054
More information about the flang-commits
mailing list