[Openmp-commits] [PATCH] D87980: [OpenMP] Protect unrecogonized CUDA error code

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Sep 21 10:43:18 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG03111e5e7a86: [OpenMP] Protect unrecogonized CUDA error code (authored by ye-luo, committed by tianshilei1992).
Herald added a project: OpenMP.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87980/new/

https://reviews.llvm.org/D87980

Files:
  openmp/libomptarget/plugins/cuda/src/rtl.cpp


Index: openmp/libomptarget/plugins/cuda/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -30,9 +30,17 @@
 #define CUDA_ERR_STRING(err)                                                   \
   do {                                                                         \
     if (getDebugLevel() > 0) {                                                 \
-      const char *errStr;                                                      \
-      cuGetErrorString(err, &errStr);                                          \
-      DP("CUDA error is: %s\n", errStr);                                       \
+      const char *errStr = nullptr;                                            \
+      CUresult errStr_status = cuGetErrorString(err, &errStr);                 \
+      if (errStr_status == CUDA_ERROR_INVALID_VALUE)                           \
+        DP("Unrecognized CUDA error code: %d\n", err);                         \
+      else if (errStr_status == CUDA_SUCCESS)                                  \
+        DP("CUDA error is: %s\n", errStr);                                     \
+      else {                                                                   \
+        DP("Unresolved CUDA error code: %d\n", err);                           \
+        DP("Unsuccessful cuGetErrorString return status: %d\n",                \
+           errStr_status);                                                     \
+      }                                                                        \
     }                                                                          \
   } while (false)
 #else // OMPTARGET_DEBUG


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87980.293216.patch
Type: text/x-patch
Size: 1758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200921/11bb71eb/attachment.bin>


More information about the Openmp-commits mailing list