[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

git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@367910 91177308-0d34-0410-b5e6-96231b3b80d8
2 files changed