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

Ye Luo via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Sep 19 20:44:33 PDT 2020


ye-luo updated this revision to Diff 293001.

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
@@ -31,8 +31,11 @@
   do {                                                                         \
     if (getDebugLevel() > 0) {                                                 \
       const char *errStr;                                                      \
-      cuGetErrorString(err, &errStr);                                          \
-      DP("CUDA error is: %s\n", errStr);                                       \
+      CUresult errStr_status = cuGetErrorString(err, &errStr);                 \
+      if (errStr_status != CUDA_SUCCESS)                                       \
+        DP("unrecognized CUDA error code: %d\n", err);                         \
+      else                                                                     \
+        DP("CUDA error is: %s\n", errStr);                                     \
     }                                                                          \
   } while (false)
 #else // OMPTARGET_DEBUG


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87980.293001.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200920/1d71ed83/attachment.bin>


More information about the Openmp-commits mailing list