[Openmp-commits] [PATCH] D94095: [libomptarget] Allow calls to omp_target_memcpy with 0 size.
George Rokos via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Tue Jan 5 08:39:34 PST 2021
grokos created this revision.
grokos added reviewers: Hahnfeld, jdoerfert, JonChesterfield, ABataev, hbae.
grokos added a project: OpenMP.
grokos requested review of this revision.
Herald added a subscriber: sstefan1.
Currently, calling `omp_target_memcpy` with 0 size is treated as an error and the function returns `OFFLOAD_FAIL`. However, there is nothing in the standard prohibiting a 0-length memcpy. This patch changes the current behavior and makes `omp_target_memcpy` return immediately with `OFFLOAD_SUCCESS` if length is 0.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94095
Files:
openmp/libomptarget/src/api.cpp
Index: openmp/libomptarget/src/api.cpp
===================================================================
--- openmp/libomptarget/src/api.cpp
+++ openmp/libomptarget/src/api.cpp
@@ -136,7 +136,12 @@
"src offset %zu, length %zu\n", dst_device, src_device, DPxPTR(dst),
DPxPTR(src), dst_offset, src_offset, length);
- if (!dst || !src || length <= 0) {
+ if (length == 0) {
+ DP("Call to omp_target_memcpy with zero length, nothing to do\n");
+ return OFFLOAD_SUCCESS;
+ }
+
+ if (!dst || !src || length < 0) {
REPORT("Call to omp_target_memcpy with invalid arguments\n");
return OFFLOAD_FAIL;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94095.314624.patch
Type: text/x-patch
Size: 634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210105/8d6cb921/attachment-0001.bin>
More information about the Openmp-commits
mailing list