[llvm] [flang][cuda] Update condition in descriptor data transfer (PR #148306)
Valentin Clement バレンタイン クレメン via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 11 15:07:24 PDT 2025
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/148306
When the two descriptor have the same number of elements and are contiguous, the transfer can be done via pointers.
>From 2c5ed8bb0294d682df960af70a42b5bc1755026b Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 11 Jul 2025 15:06:05 -0700
Subject: [PATCH] [flang][cuda] Update condition in descriptor data transfer
---
flang-rt/lib/cuda/memory.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/flang-rt/lib/cuda/memory.cpp b/flang-rt/lib/cuda/memory.cpp
index e4e13fa825f3b..d830580e6a066 100644
--- a/flang-rt/lib/cuda/memory.cpp
+++ b/flang-rt/lib/cuda/memory.cpp
@@ -110,14 +110,12 @@ void RTDECL(CUFDataTransferDescDesc)(Descriptor *dstDesc, Descriptor *srcDesc,
dstDesc->ApplyMold(*srcDesc, dstDesc->rank());
dstDesc->Allocate(/*asyncObject=*/nullptr);
}
- if ((srcDesc->rank() > 0) && (dstDesc->Elements() < srcDesc->Elements())) {
+ if ((srcDesc->rank() > 0) && (dstDesc->Elements() <= srcDesc->Elements()) &&
+ srcDesc->IsContiguous() && dstDesc->IsContiguous()) {
// Special case when rhs is bigger than lhs and both are contiguous arrays.
// In this case we do a simple ptr to ptr transfer with the size of lhs.
// This is be allowed in the reference compiler and it avoids error
// triggered in the Assign runtime function used for the main case below.
- if (!srcDesc->IsContiguous() || !dstDesc->IsContiguous())
- terminator.Crash("Unsupported data transfer: mismatching element counts "
- "with non-contiguous arrays");
RTNAME(CUFDataTransferPtrPtr)(dstDesc->raw().base_addr,
srcDesc->raw().base_addr, dstDesc->Elements() * dstDesc->ElementBytes(),
mode, sourceFile, sourceLine);
More information about the llvm-commits
mailing list