1 #ifndef HeterogeneousCore_CUDAUtilities_cudaCheck_h
2 #define HeterogeneousCore_CUDAUtilities_cudaCheck_h
13 #include <cuda_runtime.h>
26 std::string_view
description = std::string_view()) {
27 std::ostringstream
out;
29 out << file <<
", line " << line <<
":\n";
30 out <<
"cudaCheck(" << cmd <<
");\n";
31 out << error <<
": " << message <<
"\n";
34 throw std::runtime_error(out.str());
41 std::string_view
description = std::string_view()) {
42 if (
LIKELY(result == CUDA_SUCCESS))
47 cuGetErrorName(result, &error);
48 cuGetErrorString(result, &message);
57 std::string_view
description = std::string_view()) {
58 if (
LIKELY(result == cudaSuccess))
61 const char* error = cudaGetErrorName(result);
62 const char* message = cudaGetErrorString(result);
69 #define cudaCheck(ARG, ...) (cms::cuda::cudaCheck_(__FILE__, __LINE__, #ARG, (ARG), ##__VA_ARGS__))
71 #endif // HeterogeneousCore_CUDAUtilities_cudaCheck_h
bool cudaCheck_(const char *file, int line, const char *cmd, CUresult result, std::string_view description=std::string_view())
void abortOnCudaError(const char *file, int line, const char *cmd, const char *error, const char *message, std::string_view description=std::string_view())