diff options
author | Valentin Clement (バレンタイン クレメン) <clementval@gmail.com> | 2024-06-18 13:09:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 13:09:37 -0700 |
commit | 5e20785edc39854751e78dbd102fc9e6fa740fc5 (patch) | |
tree | a24ed3aaeddf82714eaefaa24b546608797aaf56 /flang | |
parent | 887bd73d7204a9ae80c608bb7113710be925384b (diff) | |
download | llvm-5e20785edc39854751e78dbd102fc9e6fa740fc5.zip llvm-5e20785edc39854751e78dbd102fc9e6fa740fc5.tar.gz llvm-5e20785edc39854751e78dbd102fc9e6fa740fc5.tar.bz2 |
[flang][cuda] Relax cuf.data_transfer verifier (#95974)
Allow data transfer between array reference and array described by a
descriptor.
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp | 6 | ||||
-rw-r--r-- | flang/test/Lower/CUDA/cuda-data-transfer.cuf | 16 |
2 files changed, 20 insertions, 2 deletions
diff --git a/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp b/flang/lib/Optimizer/Dialect/CUF/CUFOps.cpp index 00b706f..4fa1d39 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 42fa4d0..3b407b9 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>> |