Print NVML return code as string

pull/131/head
jackun 4 years ago
parent a9311bb578
commit 6576a0a09c
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -161,6 +161,19 @@ bool libnvml_loader::Load(const std::string& library_name) {
return false;
}
#if defined(LIBRARY_LOADER_NVML_H_DLOPEN)
nvmlErrorString =
reinterpret_cast<decltype(this->nvmlErrorString)>(
dlsym(library_, "nvmlErrorString"));
#endif
#if defined(LIBRARY_LOADER_NVML_H_DT_NEEDED)
nvmlErrorString = &::nvmlErrorString;
#endif
if (!nvmlErrorString) {
CleanUp(true);
return false;
}
loaded_ = true;
return true;
}

@ -31,6 +31,7 @@ class libnvml_loader {
decltype(&::nvmlDeviceGetHandleByPciBusId_v2) nvmlDeviceGetHandleByPciBusId_v2;
decltype(&::nvmlDeviceGetMemoryInfo) nvmlDeviceGetMemoryInfo;
decltype(&::nvmlDeviceGetClockInfo) nvmlDeviceGetClockInfo;
decltype(&::nvmlErrorString) nvmlErrorString;
private:
void CleanUp(bool unload);

@ -22,10 +22,14 @@ bool checkNVML(const char* pciBusId){
ret = nvml.nvmlDeviceGetHandleByPciBusId(pciBusId, &nvidiaDevice);
if (ret != NVML_SUCCESS) {
std::cerr << "MANGOHUD: Getting handle by PCI bus ID failed! Using index 0.\n";
std::cerr << "MANGOHUD: Getting device handle by PCI bus ID failed: " << nvml.nvmlErrorString(ret) << "\n";
std::cerr << " Using index 0.\n";
ret = nvml.nvmlDeviceGetHandleByIndex(0, &nvidiaDevice);
}
if (ret != NVML_SUCCESS)
std::cerr << "MANGOHUD: Getting device handle failed: " << nvml.nvmlErrorString(ret) << "\n";
nvmlSuccess = (ret == NVML_SUCCESS);
return nvmlSuccess;
}

Loading…
Cancel
Save