[Openmp-commits] [PATCH] D96067: [OpenMP][libomptarget] Fixed an issue that device sync is skipped if the kernel doesn't have any argument
Shilei Tian via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Feb 4 17:14:43 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb68a6b09e60a: [OpenMP][libomptarget] Fixed an issue that device sync is skipped if the kernel… (authored by tianshilei1992).
Changed prior to commit:
https://reviews.llvm.org/D96067?vs=321525&id=321621#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96067/new/
https://reviews.llvm.org/D96067
Files:
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/test/offloading/assert.cpp
Index: openmp/libomptarget/test/offloading/assert.cpp
===================================================================
--- /dev/null
+++ openmp/libomptarget/test/offloading/assert.cpp
@@ -0,0 +1,8 @@
+// RUN: %libomptarget-compilexx-nvptx64-nvidia-cuda && %libomptarget-run-fail-nvptx64-nvidia-cuda
+
+int main(int argc, char *argv[]) {
+#pragma omp target
+ { __builtin_trap(); }
+
+ return 0;
+}
Index: openmp/libomptarget/src/omptarget.cpp
===================================================================
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -451,6 +451,17 @@
: HstPtrBegin(HstPtr), DataSize(Size), ForceDelete(ForceDelete),
HasCloseModifier(HasCloseModifier) {}
};
+
+/// Synchronize device
+static int syncDevice(DeviceTy &Device, __tgt_async_info *AsyncInfo) {
+ assert(AsyncInfo && AsyncInfo->Queue && "Invalid AsyncInfo");
+ if (Device.synchronize(AsyncInfo) != OFFLOAD_SUCCESS) {
+ REPORT("Failed to synchronize device.\n");
+ return OFFLOAD_FAIL;
+ }
+
+ return OFFLOAD_SUCCESS;
+}
} // namespace
/// Internal function to undo the mapping and retrieve the data from the device.
@@ -631,11 +642,9 @@
// AsyncInfo->Queue will not be nullptr, so again, we don't need to
// synchronize.
if (AsyncInfo && AsyncInfo->Queue) {
- Ret = Device.synchronize(AsyncInfo);
- if (Ret != OFFLOAD_SUCCESS) {
- REPORT("Failed to synchronize device.\n");
+ Ret = syncDevice(Device, AsyncInfo);
+ if (Ret != OFFLOAD_SUCCESS)
return OFFLOAD_FAIL;
- }
}
// Deallocate target pointer
@@ -1307,6 +1316,11 @@
REPORT("Failed to process data after launching the kernel.\n");
return OFFLOAD_FAIL;
}
+ } else if (AsyncInfo.Queue) {
+ // If ArgNum is zero, but AsyncInfo.Queue is valid, then the kernel doesn't
+ // hava any argument, and the device supports async operations, so we need a
+ // sync at this point.
+ return syncDevice(Device, &AsyncInfo);
}
return OFFLOAD_SUCCESS;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96067.321621.patch
Type: text/x-patch
Size: 2035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210205/b670aba2/attachment.bin>
More information about the Openmp-commits
mailing list