[Openmp-commits] [openmp] 5f6aa96 - [OpenMP] target_data_begin: fail on device alloc fail
Joel E. Denny via Openmp-commits
openmp-commits at lists.llvm.org
Tue Apr 21 14:13:34 PDT 2020
Author: Joel E. Denny
Date: 2020-04-21T17:10:50-04:00
New Revision: 5f6aa9680c19534a382cb652178e0ff6edbe78de
URL: https://github.com/llvm/llvm-project/commit/5f6aa9680c19534a382cb652178e0ff6edbe78de
DIFF: https://github.com/llvm/llvm-project/commit/5f6aa9680c19534a382cb652178e0ff6edbe78de.diff
LOG: [OpenMP] target_data_begin: fail on device alloc fail
Without this patch, target_data_begin continues after an illegal
mapping or an out-of-memory error on the device. With this patch, it
terminates the runtime with an error instead.
The new test exercises only illegal mappings. I didn't think of a
good way to exercise out-of-memory errors from the test suite.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D78170
Added:
openmp/libomptarget/test/mapping/alloc_fail.c
Modified:
openmp/libomptarget/src/omptarget.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp
index 3113bdc2a9d3..df7481a34805 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -286,6 +286,7 @@ int target_data_begin(DeviceTy &Device, int32_t arg_num, void **args_base,
// NULL, so getOrAlloc() returning NULL is not an error.
DP("Call to getOrAllocTgtPtr returned null pointer (device failure or "
"illegal mapping).\n");
+ return OFFLOAD_FAIL;
}
DP("There are %" PRId64 " bytes allocated at target address " DPxMOD
" - is%s new\n", data_size, DPxPTR(TgtPtrBegin),
diff --git a/openmp/libomptarget/test/mapping/alloc_fail.c b/openmp/libomptarget/test/mapping/alloc_fail.c
new file mode 100644
index 000000000000..ca15a429f130
--- /dev/null
+++ b/openmp/libomptarget/test/mapping/alloc_fail.c
@@ -0,0 +1,25 @@
+// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu
+// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \
+// RUN: | %fcheck-aarch64-unknown-linux-gnu
+
+// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu
+// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \
+// RUN: | %fcheck-powerpc64-ibm-linux-gnu
+
+// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu
+// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \
+// RUN: | %fcheck-powerpc64le-ibm-linux-gnu
+
+// RUN: %libomptarget-compile-x86_64-pc-linux-gnu
+// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \
+// RUN: | %fcheck-x86_64-pc-linux-gnu
+
+// CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
+
+int main() {
+ int arr[4] = {0, 1, 2, 3};
+#pragma omp target data map(alloc: arr[0:2])
+#pragma omp target data map(alloc: arr[1:2])
+ ;
+ return 0;
+}
More information about the Openmp-commits
mailing list