[flang-commits] [flang] [flang][cuda] Update cuda data transfer rules for full managed assigment (PR #175243)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Fri Jan 9 14:55:53 PST 2026
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/175243 at github.com>
https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/175243
>From 27238c70252680d8cbc6832bc503640dd882c931 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 9 Jan 2026 12:52:21 -0800
Subject: [PATCH 1/2] [flang][cuda] Update cuda data transfer rules for full
managed assignment
---
flang/include/flang/Evaluate/tools.h | 3 +--
flang/test/Lower/CUDA/cuda-data-transfer.cuf | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/flang/include/flang/Evaluate/tools.h b/flang/include/flang/Evaluate/tools.h
index ea26a0ee9da7a..6a424f2cbb04e 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -1352,8 +1352,7 @@ inline bool IsCUDADataTransfer(const A &lhs, const B &rhs) {
// Special cases performed on the host:
// - Only managed or unifed symbols are involved on RHS and LHS.
// - LHS is managed or unified and the RHS is host only.
- if ((lhsNbManagedSymbols >= 1 && rhsNbManagedSymbols == 1 &&
- rhsNbSymbols == 1) ||
+ if ((lhsNbManagedSymbols >= 1 && rhsNbManagedSymbols == rhsNbSymbols) ||
(lhsNbManagedSymbols >= 1 && rhsNbSymbols == 0)) {
return false;
}
diff --git a/flang/test/Lower/CUDA/cuda-data-transfer.cuf b/flang/test/Lower/CUDA/cuda-data-transfer.cuf
index 058e2506c1d53..0c14f960bbb29 100644
--- a/flang/test/Lower/CUDA/cuda-data-transfer.cuf
+++ b/flang/test/Lower/CUDA/cuda-data-transfer.cuf
@@ -588,3 +588,19 @@ end subroutine
! CHECK: %{{.*}} = cuf.alloc !fir.type<_QMmod1Tt3{spheres:!fir.box<!fir.heap<!fir.array<?x!fir.type<_QMmod1Ts{c:!fir.array<3xf32>}>>>>}> {bindc_name = "t", data_attr = #cuf.cuda<managed>, uniq_name = "_QFsub30Et"} -> !fir.ref<!fir.type<_QMmod1Tt3{spheres:!fir.box<!fir.heap<!fir.array<?x!fir.type<_QMmod1Ts{c:!fir.array<3xf32>}>>>>}>>
! CHECK: hlfir.assign
! CHECK-NOT: cuf.data_transfer
+
+! Test that assigment with onlt managed variables on both rhs and lhs is done
+! on the host.
+
+subroutine sub31()
+ type :: t30
+ real, managed, allocatable :: q(:)
+ end type
+ type(t30), managed, allocatable :: x(:)
+ x(4)%q = x(3)%q
+end subroutine
+
+! CHECK-LABEL: func.func @_QPsub31()
+! CHECK: cuf.alloc !fir.box<!fir.heap<!fir.array<?x!fir.type<_QFsub31Tt30{q:!fir.box<!fir.heap<!fir.array<?xf32>>>}>>>>
+! CHECK: hlfir.assign
+! CHECK-NOT: cuf.data_transfer
>From 81ba34db8c51983ac1f3635140dfb4d885d5e6ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Valentin=20Clement=20=28=E3=83=90=E3=83=AC=E3=83=B3?=
=?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=B3=20=E3=82=AF=E3=83=AC=E3=83=A1?=
=?UTF-8?q?=E3=83=B3=29?= <clementval at gmail.com>
Date: Fri, 9 Jan 2026 14:55:45 -0800
Subject: [PATCH 2/2] Apply suggestion from @clementval
---
flang/test/Lower/CUDA/cuda-data-transfer.cuf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/test/Lower/CUDA/cuda-data-transfer.cuf b/flang/test/Lower/CUDA/cuda-data-transfer.cuf
index 0c14f960bbb29..4e96a350a61f3 100644
--- a/flang/test/Lower/CUDA/cuda-data-transfer.cuf
+++ b/flang/test/Lower/CUDA/cuda-data-transfer.cuf
@@ -589,7 +589,7 @@ end subroutine
! CHECK: hlfir.assign
! CHECK-NOT: cuf.data_transfer
-! Test that assigment with onlt managed variables on both rhs and lhs is done
+! Test that assigment with only managed variables on both rhs and lhs is done
! on the host.
subroutine sub31()
More information about the flang-commits
mailing list