diff options
| author | Michael Kruse <llvm@meinersbur.de> | 2019-08-05 19:12:10 +0000 |
|---|---|---|
| committer | Michael Kruse <llvm@meinersbur.de> | 2019-08-05 19:12:10 +0000 |
| commit | 78769ec403873ba243a5131150851f5ffaec6e9d (patch) | |
| tree | eaff4de369b7eb4713f5c687d4ab3224e7a90c8a | |
| parent | 8820b122b3ec42e4ff7d7606c1aa6af1d5e40455 (diff) | |
| download | bcm5719-llvm-78769ec403873ba243a5131150851f5ffaec6e9d.tar.gz bcm5719-llvm-78769ec403873ba243a5131150851f5ffaec6e9d.zip | |
[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@gmail.com>
Differential Revision: https://reviews.llvm.org/D65687
llvm-svn: 367910
| -rw-r--r-- | openmp/libomptarget/plugins/cuda/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | openmp/libomptarget/plugins/cuda/src/rtl.cpp | 24 |
2 files changed, 11 insertions, 17 deletions
diff --git a/openmp/libomptarget/plugins/cuda/CMakeLists.txt b/openmp/libomptarget/plugins/cuda/CMakeLists.txt index 5fab421c42f..06c3dd94878 100644 --- a/openmp/libomptarget/plugins/cuda/CMakeLists.txt +++ b/openmp/libomptarget/plugins/cuda/CMakeLists.txt @@ -28,10 +28,6 @@ libomptarget_say("Building CUDA offloading plugin.") # 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}) diff --git a/openmp/libomptarget/plugins/cuda/src/rtl.cpp b/openmp/libomptarget/plugins/cuda/src/rtl.cpp index 04a3ddc4002..4a7264401d7 100644 --- a/openmp/libomptarget/plugins/cuda/src/rtl.cpp +++ b/openmp/libomptarget/plugins/cuda/src/rtl.cpp @@ -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; |

