From 7a2fe83aaa911507a0631205a72b58a0017b93a1 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 14 Nov 2014 21:49:30 +0100 Subject: [PATCH] nvapi: match gpu index with pci/x bus id mapping by Name was a quick test... --- nvml.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nvml.cpp b/nvml.cpp index 7d402bf..abff6cf 100644 --- a/nvml.cpp +++ b/nvml.cpp @@ -31,7 +31,6 @@ extern wrap_nvml_handle *hnvml; extern int num_processors; // gpus extern int device_map[8]; -extern char* device_name[8]; static uint32_t device_bus_ids[8] = { 0 }; @@ -462,14 +461,21 @@ int wrap_nvapi_init() return -1; } + for (int g = 0; g < num_processors; g++) { + cudaDeviceProp props; + if (cudaGetDeviceProperties(&props, g) == cudaSuccess) + device_bus_ids[g] = props.pciBusID; + } + for (NvU8 i = 0; i < nvapi_dev_cnt; i++) { NvAPI_ShortString name; nvapi_dev_map[i] = i; // default mapping ret = NvAPI_GPU_GetFullName(phys[i], name); if (ret == NVAPI_OK) { for (int g = 0; g < num_processors; g++) { - //todo : device_bus_ids, could be wrong on rigs - if (strcmp(device_name[g], name) == 0 && nvapi_dev_map[i] == i) { + NvU32 busId; + ret = NvAPI_GPU_GetBusId(phys[i], &busId); + if (ret == NVAPI_OK && busId == device_bus_ids[g]) { nvapi_dev_map[i] = g; break; } @@ -562,7 +568,6 @@ int gpu_pstate(struct cgpu_info *gpu) if (support == -1) { unsigned int pst = 0; nvapi_getpstate(nvapi_dev_map[gpu->thr_id], &pst); - //todo : convert ? pstate = (int) pst; } #endif