[Openmp-commits] [PATCH] D130371: [Libomptarget] Don't report lack of CUDA devices
Joel E. Denny via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jul 22 11:50:31 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcfa6e79df30c: [Libomptarget] Don't report lack of CUDA devices (authored by jdenny).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130371/new/
https://reviews.llvm.org/D130371
Files:
openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.h
openmp/libomptarget/plugins/cuda/src/rtl.cpp
openmp/libomptarget/test/offloading/cuda_no_devices.c
Index: openmp/libomptarget/test/offloading/cuda_no_devices.c
===================================================================
--- /dev/null
+++ openmp/libomptarget/test/offloading/cuda_no_devices.c
@@ -0,0 +1,20 @@
+// The CUDA plugin used to complain on stderr when no CUDA devices were enabled,
+// and then it let the application run anyway. Check that there's no such
+// complaint anymore, especially when the user isn't targeting CUDA.
+
+// RUN: %libomptarget-compile-generic
+// RUN: env CUDA_VISIBLE_DEVICES= \
+// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
+
+#include <stdio.h>
+
+// CHECK-NOT: {{.}}
+// CHECK: Hello World: 4
+// CHECK-NOT: {{.}}
+int main() {
+ int x = 0;
+ #pragma omp target teams num_teams(2) reduction(+:x)
+ x += 2;
+ printf("Hello World: %d\n", x);
+ return 0;
+}
Index: openmp/libomptarget/plugins/cuda/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -507,6 +507,10 @@
DP("Failed to load CUDA shared library\n");
return;
}
+ if (Err == CUDA_ERROR_NO_DEVICE) {
+ DP("There are no devices supporting CUDA.\n");
+ return;
+ }
if (!checkResult(Err, "Error returned from cuInit\n")) {
return;
}
Index: openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.h
===================================================================
--- openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.h
+++ openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.h
@@ -27,6 +27,7 @@
typedef enum cudaError_enum {
CUDA_SUCCESS = 0,
CUDA_ERROR_INVALID_VALUE = 1,
+ CUDA_ERROR_NO_DEVICE = 100,
CUDA_ERROR_INVALID_HANDLE = 400,
} CUresult;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130371.446917.patch
Type: text/x-patch
Size: 1765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220722/55731a56/attachment.bin>
More information about the Openmp-commits
mailing list