[flang-commits] [flang] 5e20785 - [flang][cuda] Relax cuf.data_transfer verifier (#95974)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 18 13:09:40 PDT 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-06-18T13:09:37-07:00
New Revision: 5e20785edc39854751e78dbd102fc9e6fa740fc5
URL: https://github.com/llvm/llvm-project/commit/5e20785edc39854751e78dbd102fc9e6fa740fc5
DIFF: https://github.com/llvm/llvm-project/commit/5e20785edc39854751e78dbd102fc9e6fa740fc5.diff
LOG: [flang][cuda] Relax cuf.data_transfer verifier (#95974)
Allow data transfer between array reference and array described by a
descriptor.
Added:
Modified:
flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
flang/test/Lower/CUDA/cuda-data-transfer.cuf
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
index 00b706fec903f..4fa1d3986b219 100644
--- a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
+++ b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp
@@ -98,13 +98,15 @@ mlir::LogicalResult cuf::DataTransferOp::verify() {
mlir::Type srcTy = getSrc().getType();
mlir::Type dstTy = getDst().getType();
if ((fir::isa_ref_type(srcTy) && fir::isa_ref_type(dstTy)) ||
- (fir::isa_box_type(srcTy) && fir::isa_box_type(dstTy)))
+ (fir::isa_box_type(srcTy) && fir::isa_box_type(dstTy)) ||
+ (fir::isa_ref_type(srcTy) && fir::isa_box_type(dstTy)) ||
+ (fir::isa_box_type(srcTy) && fir::isa_ref_type(dstTy)))
return mlir::success();
if (fir::isa_trivial(srcTy) &&
matchPattern(getSrc().getDefiningOp(), mlir::m_Constant()))
return mlir::success();
return emitOpError()
- << "expect src and dst to be both references or descriptors or src to "
+ << "expect src and dst to be references or descriptors or src to "
"be a constant";
}
diff --git a/flang/test/Lower/CUDA/cuda-data-transfer.cuf b/flang/test/Lower/CUDA/cuda-data-transfer.cuf
index 42fa4d09c95e0..3b407b9c35faf 100644
--- a/flang/test/Lower/CUDA/cuda-data-transfer.cuf
+++ b/flang/test/Lower/CUDA/cuda-data-transfer.cuf
@@ -179,3 +179,19 @@ end subroutine
! CHECK: cuf.data_transfer %[[A]]#0 to %[[B]]#0 {transfer_kind = #cuf.cuda_transfer<device_host>} : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
! CHECK: cuf.data_transfer %[[B]]#0 to %[[A]]#0 {transfer_kind = #cuf.cuda_transfer<host_device>} : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
! CHECK: cuf.data_transfer %[[A]]#0 to %[[C]]#0 {transfer_kind = #cuf.cuda_transfer<device_device>} : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+
+
+subroutine sub8(a, b, n)
+ integer :: n
+ integer, device :: a(n)
+ integer :: b(10)
+ b = a
+ a = b
+end subroutine
+
+! CHECK-LABEL: func.func @_QPsub8(
+! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.array<?xi32>> {cuf.data_attr = #cuf.cuda<device>, fir.bindc_name = "a"}, %[[ARG1:.*]]: !fir.ref<!fir.array<10xi32>> {fir.bindc_name = "b"}, %[[ARG2:.*]]: !fir.ref<i32> {fir.bindc_name = "n"})
+! CHECK: %[[B:.*]]:2 = hlfir.declare %[[ARG1]](%{{.*}}) dummy_scope %{{.*}} {uniq_name = "_QFsub8Eb"} : (!fir.ref<!fir.array<10xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.ref<!fir.array<10xi32>>, !fir.ref<!fir.array<10xi32>>)
+! CHECK: %[[A:.*]]:2 = hlfir.declare %[[ARG0]](%{{.*}}) dummy_scope %{{.*}} {data_attr = #cuf.cuda<device>, uniq_name = "_QFsub8Ea"} : (!fir.ref<!fir.array<?xi32>>, !fir.shape<1>, !fir.dscope) -> (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<?xi32>>)
+! CHECK: cuf.data_transfer %[[A]]#0 to %[[B]]#0 {transfer_kind = #cuf.cuda_transfer<device_host>} : !fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<10xi32>>
+! CHECK: cuf.data_transfer %[[B]]#0 to %[[A]]#0 {transfer_kind = #cuf.cuda_transfer<host_device>} : !fir.ref<!fir.array<10xi32>>, !fir.box<!fir.array<?xi32>>
More information about the flang-commits
mailing list