From e23b577e32c55bbf3b0c8e4476985488ad47e333 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sat, 6 May 2017 01:23:20 +0200 Subject: [PATCH] nvml: show product ids and pci bus in ccminer -D -n --- nvml.cpp | 16 ++++++++++++++-- nvml.h | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/nvml.cpp b/nvml.cpp index 2fd40bc..08c37e6 100644 --- a/nvml.cpp +++ b/nvml.cpp @@ -240,6 +240,7 @@ nvml_handle * nvml_create() nvmlh->nvml_pci_domain_id = (unsigned int*) calloc(nvmlh->nvml_gpucount, sizeof(unsigned int)); nvmlh->nvml_pci_bus_id = (unsigned int*) calloc(nvmlh->nvml_gpucount, sizeof(unsigned int)); nvmlh->nvml_pci_device_id = (unsigned int*) calloc(nvmlh->nvml_gpucount, sizeof(unsigned int)); + nvmlh->nvml_pci_vendor_id = (unsigned int*) calloc(nvmlh->nvml_gpucount, sizeof(unsigned int)); nvmlh->nvml_pci_subsys_id = (unsigned int*) calloc(nvmlh->nvml_gpucount, sizeof(unsigned int)); nvmlh->nvml_cuda_device_id = (int*) calloc(nvmlh->nvml_gpucount, sizeof(int)); nvmlh->cuda_nvml_device_id = (int*) calloc(nvmlh->cuda_gpucount, sizeof(int)); @@ -259,6 +260,7 @@ nvml_handle * nvml_create() nvmlh->nvml_pci_domain_id[i] = pciinfo.domain; nvmlh->nvml_pci_bus_id[i] = pciinfo.bus; nvmlh->nvml_pci_device_id[i] = pciinfo.device; + nvmlh->nvml_pci_vendor_id[i] = pciinfo.pci_device_id; nvmlh->nvml_pci_subsys_id[i] = pciinfo.pci_subsystem_id; nvmlh->app_clocks[i] = NVML_FEATURE_UNKNOWN; @@ -563,6 +565,15 @@ void nvml_print_device_info(int dev_id) nvmlReturn_t rc; + // fprintf(stderr, "------ Hardware ------\n"); + int gvid = hnvml->nvml_pci_vendor_id[n] & 0xFFFF; + int gpid = hnvml->nvml_pci_vendor_id[n] >> 16; + int svid = hnvml->nvml_pci_subsys_id[n] & 0xFFFF; + int spid = hnvml->nvml_pci_subsys_id[n] >> 16; + + fprintf(stderr, LSTDEV_PFX "ID %04x:%04x/%04x:%04x BUS %04x:%02x:%02x.0\n", gvid, gpid, svid, spid, + (int) hnvml->nvml_pci_domain_id[n], (int) hnvml->nvml_pci_bus_id[n], (int) hnvml->nvml_pci_device_id[n]); + if (hnvml->nvmlDeviceGetClock) { uint32_t gpu_clk = 0, mem_clk = 0; @@ -778,11 +789,11 @@ int nvml_get_info(nvml_handle *nvmlh, int cudaindex, uint16_t &vid, uint16_t &pi return -ENODEV; subids = nvmlh->nvml_pci_subsys_id[gpuindex]; - if (!subids) subids = nvmlh->nvml_pci_device_id[gpuindex]; + if (!subids) subids = nvmlh->nvml_pci_vendor_id[gpuindex]; pid = subids >> 16; vid = subids & 0xFFFF; // Colorful and Inno3D - if (pid == 0) pid = nvmlh->nvml_pci_device_id[gpuindex] >> 16; + if (pid == 0) pid = nvmlh->nvml_pci_vendor_id[gpuindex] >> 16; return 0; } @@ -795,6 +806,7 @@ int nvml_destroy(nvml_handle *nvmlh) free(nvmlh->nvml_pci_bus_id); free(nvmlh->nvml_pci_device_id); free(nvmlh->nvml_pci_domain_id); + free(nvmlh->nvml_pci_vendor_id); free(nvmlh->nvml_pci_subsys_id); free(nvmlh->nvml_cuda_device_id); free(nvmlh->cuda_nvml_device_id); diff --git a/nvml.h b/nvml.h index fd8de2f..bb311a5 100644 --- a/nvml.h +++ b/nvml.h @@ -21,9 +21,11 @@ void *monitor_thread(void *userdata); typedef void * nvmlDevice_t; +#define NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE 16 + /* our own version of the PCI info struct */ typedef struct { - char bus_id_str[16]; /* string form of bus info */ + char bus_id_str[NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE]; unsigned int domain; unsigned int bus; unsigned int device; @@ -121,6 +123,7 @@ typedef struct { unsigned int *nvml_pci_domain_id; unsigned int *nvml_pci_bus_id; unsigned int *nvml_pci_device_id; + unsigned int *nvml_pci_vendor_id; unsigned int *nvml_pci_subsys_id; int *nvml_cuda_device_id; /* map NVML dev to CUDA dev */ int *cuda_nvml_device_id; /* map CUDA dev to NVML dev */