[Openmp-commits] [openmp] r367910 - [libomptarget] Harmonize emitting CUDA errors and general debug messages.
Michael Kruse via Openmp-commits
openmp-commits at lists.llvm.org
Mon Aug 5 12:12:10 PDT 2019
Author: meinersbur
Date: Mon Aug 5 12:12:10 2019
New Revision: 367910
URL: http://llvm.org/viewvc/llvm-project?rev=367910&view=rev
Log:
[libomptarget] Harmonize emitting CUDA errors and general debug messages.
Ensures that CUDA fail reasons (such as "No CUDA-capable device detected")
are printed together with libomptarget's debug message
(e.g. "Error when setting CUDA context"). Previously, the former was
printed only in CMAKE_BUILD_TYPE=Debug builds while the latter was
enabled by LIBOMPTARGET_ENABLE_DEBUG.
With this change, also only call cuGetErrorString when the error will be
printed.
Suggested-by: Ye Luo <xw111luoye at gmail.com>
Differential Revision: https://reviews.llvm.org/D65687
Modified:
openmp/trunk/libomptarget/plugins/cuda/CMakeLists.txt
openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp
Modified: openmp/trunk/libomptarget/plugins/cuda/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/libomptarget/plugins/cuda/CMakeLists.txt?rev=367910&r1=367909&r2=367910&view=diff
==============================================================================
--- openmp/trunk/libomptarget/plugins/cuda/CMakeLists.txt (original)
+++ openmp/trunk/libomptarget/plugins/cuda/CMakeLists.txt Mon Aug 5 12:12:10 2019
@@ -28,10 +28,6 @@ libomptarget_say("Building CUDA offloadi
# Define the suffix for the runtime messaging dumps.
add_definitions(-DTARGET_NAME=CUDA)
-if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug)
- add_definitions(-DCUDA_ERROR_REPORT)
-endif()
-
include_directories(${LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS})
include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS})
Modified: openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp?rev=367910&r1=367909&r2=367910&view=diff
==============================================================================
--- openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp (original)
+++ openmp/trunk/libomptarget/plugins/cuda/src/rtl.cpp Mon Aug 5 12:12:10 2019
@@ -34,25 +34,23 @@ static int DebugLevel = 0;
DEBUGP("Target " GETNAME(TARGET_NAME) " RTL", __VA_ARGS__); \
} \
} while (false)
+
+// Utility for retrieving and printing CUDA error string.
+#define CUDA_ERR_STRING(err) \
+ do { \
+ if (DebugLevel > 0) { \
+ const char *errStr; \
+ cuGetErrorString(err, &errStr); \
+ DEBUGP("Target " GETNAME(TARGET_NAME) " RTL", "CUDA error is: %s\n", errStr); \
+ } \
+ } while (false)
#else // OMPTARGET_DEBUG
#define DP(...) {}
+#define CUDA_ERR_STRING(err) {}
#endif // OMPTARGET_DEBUG
#include "../../common/elf_common.c"
-// Utility for retrieving and printing CUDA error string.
-#ifdef CUDA_ERROR_REPORT
-#define CUDA_ERR_STRING(err) \
- do { \
- const char *errStr; \
- cuGetErrorString(err, &errStr); \
- DP("CUDA error is: %s\n", errStr); \
- } while (0)
-#else
-#define CUDA_ERR_STRING(err) \
- {}
-#endif
-
/// Keep entries table per device.
struct FuncOrGblEntryTy {
__tgt_target_table Table;
More information about the Openmp-commits
mailing list