File indexing completed on 2026-04-09 07:49:28
0001 #pragma once
0002
0003 #include <stdexcept>
0004 #include <sstream>
0005
0006 #define NVML_CHECK( call ) \
0007 do \
0008 { \
0009 nvmlReturn_t result = call; \
0010 if( result != NVML_SUCCESS ) \
0011 { \
0012 std::stringstream ss; \
0013 ss << "NVML call (" << #call << " ) failed with error: '" \
0014 << nvmlErrorString( result ) \
0015 << "' (" __FILE__ << ":" << __LINE__ << ")\n"; \
0016 throw NVML_Exception( ss.str().c_str() ); \
0017 } \
0018 } while( 0 )
0019
0020
0021
0022 #define NVML_CHECK_RC( RC, call ) \
0023 do \
0024 { \
0025 nvmlReturn_t result = call; \
0026 if( result != RC ) \
0027 { \
0028 std::stringstream ss; \
0029 ss << "NVML call (" << #call << " ) failed with error: '" \
0030 << nvmlErrorString( result ) \
0031 << "' (" __FILE__ << ":" << __LINE__ << ")\n"; \
0032 throw NVML_Exception( ss.str().c_str() ); \
0033 } \
0034 } while( 0 )
0035
0036
0037
0038
0039
0040
0041
0042
0043 struct NVML_Exception : public std::runtime_error
0044 {
0045 NVML_Exception( const char* msg ) : std::runtime_error( msg ){}
0046 };
0047