| 41 | } |
| 42 | |
| 43 | NvmlAdapterSignature NvmlWrapper::GetAdapterSignature(nvmlDevice_t adapter) const |
| 44 | { |
| 45 | // get pci information |
| 46 | nvmlPciInfo_t pciInfo{}; |
| 47 | if (!Ok(DeviceGetPciInfo_v3(adapter, &pciInfo))) |
| 48 | { |
| 49 | // TODO: log failure of this function |
| 50 | return {}; |
| 51 | } |
| 52 | |
| 53 | // fill directly fillable information into signature |
| 54 | NvmlAdapterSignature signature{ |
| 55 | .pciDeviceId = pciInfo.pciDeviceId, |
| 56 | .pciSubSystemId = pciInfo.pciSubSystemId, |
| 57 | }; |
| 58 | |
| 59 | // extract out necessary components from pciInfo. |
| 60 | // pciInfo.busId is a string with format = Domain:Bus:PciFunction.Id |
| 61 | try { |
| 62 | const std::regex expr{ "(.*?):(.*?):(.*?)\\.(.*)" }; |
| 63 | std::cmatch results; |
| 64 | if (std::regex_match(pciInfo.busId, results, expr)) |
| 65 | { |
| 66 | if (results[1].length() > 0) |
| 67 | { |
| 68 | signature.busIdDomain = std::stoul(results[1]); |
| 69 | } |
| 70 | if (results[2].length() > 0) |
| 71 | { |
| 72 | signature.busIdBus = std::stoul(results[2]); |
| 73 | } |
| 74 | } |
| 75 | } catch (...) {} |
| 76 | |
| 77 | return signature; |
| 78 | } |
| 79 | |
| 80 | // definition of wrapper functions |
| 81 | // calls function pointer if exists, otherwise return NVML error [NVML_ERROR_FUNCTION_NOT_FOUND] |
no outgoing calls
no test coverage detected