Skip to content

Commit 2696e8c

Browse files
authored
[flang][cuda] Remove too restrictive assert for data transfer (#152398)
When the rhs is a an array element, the assert was triggered but this is still a valid transfer. Remove the assert. The operation has a verifier to check its validity.
1 parent 8381f95 commit 2696e8c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4898,7 +4898,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
48984898

48994899
// device = device
49004900
if (lhsIsDevice && rhsIsDevice) {
4901-
assert(rhs.isVariable() && "CUDA Fortran assignment rhs is not legal");
49024901
auto transferKindAttr = cuf::DataTransferKindAttr::get(
49034902
builder.getContext(), cuf::DataTransferKind::DeviceDevice);
49044903
cuf::DataTransferOp::create(builder, loc, rhsVal, lhsVal, shape,

flang/test/Lower/CUDA/cuda-data-transfer.cuf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,15 @@ subroutine sub23(n)
444444
end subroutine
445445

446446
! CHECK-LABEL: func.func @_QPsub23
447+
448+
subroutine sub24()
449+
real, managed :: m
450+
real, device :: d(4)
451+
m = d(1)
452+
end
453+
454+
! CHECK-LABEL: func.func @_QPsub24()
455+
! CHECK: %[[D:.*]]:2 = hlfir.declare %1(%2) {data_attr = #cuf.cuda<device>, uniq_name = "_QFsub24Ed"} : (!fir.ref<!fir.array<4xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<4xf32>>, !fir.ref<!fir.array<4xf32>>)
456+
! CHECK: %[[M:.*]]:2 = hlfir.declare %4 {data_attr = #cuf.cuda<managed>, uniq_name = "_QFsub24Em"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
457+
! CHECK: %[[D1:.*]] = hlfir.designate %[[D]]#0 (%c1{{.*}}) : (!fir.ref<!fir.array<4xf32>>, index) -> !fir.ref<f32>
458+
! CHECK: cuf.data_transfer %[[D1]] to %[[M]]#0 {transfer_kind = #cuf.cuda_transfer<device_device>} : !fir.ref<f32>, !fir.ref<f32>

0 commit comments

Comments
 (0)