1 #ifndef HeterogeneousCore_CUDAUtilities_nvmlCheck_h
2 #define HeterogeneousCore_CUDAUtilities_nvmlCheck_h
25 std::string_view
description = std::string_view()) {
26 std::ostringstream
out;
28 out << file <<
", line " << line <<
":\n";
29 out <<
"nvmlCheck(" << cmd <<
");\n";
30 out << error <<
": " << message <<
"\n";
33 throw std::runtime_error(out.str());
40 std::string_view
description = std::string_view()) {
41 if (
LIKELY(result == NVML_SUCCESS))
44 std::string error =
"NVML Error " + std::to_string(result);
45 const char* message = nvmlErrorString(result);
52 #define nvmlCheck(ARG, ...) (cms::cuda::nvmlCheck_(__FILE__, __LINE__, #ARG, (ARG), ##__VA_ARGS__))
54 #endif // HeterogeneousCore_CUDAUtilities_nvmlCheck_h
void abortOnNvmlError(const char *file, int line, const char *cmd, const char *error, const char *message, std::string_view description=std::string_view())
bool nvmlCheck_(const char *file, int line, const char *cmd, nvmlReturn_t result, std::string_view description=std::string_view())