Browse Source

api: restore bios, can be useful to identify

We have no way yet to identify a MSI 750 from a Gigabyte one...
master
Tanguy Pruvot 10 years ago
parent
commit
484bbc4b15
  1. 5
      api.cpp
  2. 58
      nvml.cpp
  3. 2
      nvml.h

5
api.cpp

@ -246,10 +246,11 @@ static void gpuhwinfos(int gpu_id) @@ -246,10 +246,11 @@ static void gpuhwinfos(int gpu_id)
snprintf(buf, sizeof(buf), "GPU=%d;BUS=%hd;CARD=%s;MEM=%lu;"
"TEMP=%.1f;FAN=%d;FREQ=%d;MEMFREQ=%d;PST=%s;"
"VID=%hx;PID=%hx;NVML=%d;NVAPI=%d;DRIVER=%s|",
"VID=%hx;PID=%hx;NVML=%d;NVAPI=%d;DRIVER=%s;BIOS=%s|",
gpu_id, cgpu->gpu_bus, card, cgpu->gpu_mem,
cgpu->gpu_temp, cgpu->gpu_fan, cgpu->gpu_clock, cgpu->gpu_memclock,
pstate, cgpu->gpu_vid, cgpu->gpu_pid, cgpu->nvml_id, cgpu->nvapi_id, driver_version);
pstate, cgpu->gpu_vid, cgpu->gpu_pid, cgpu->nvml_id, cgpu->nvapi_id,
driver_version, cgpu->gpu_desc);
strcat(buffer, buf);
}

58
nvml.cpp

@ -137,8 +137,10 @@ wrap_nvml_handle * wrap_nvml_create() @@ -137,8 +137,10 @@ wrap_nvml_handle * wrap_nvml_create()
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetFanSpeed");
nvmlh->nvmlDeviceGetPerformanceState = (wrap_nvmlReturn_t (*)(wrap_nvmlDevice_t, int *))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetPowerUsage");
nvmlh->nvmlDeviceGetPowerUsage = (wrap_nvmlReturn_t (*)(wrap_nvmlDevice_t, unsigned int *))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetPowerUsage");
nvmlh->nvmlDeviceGetUUID = (wrap_nvmlReturn_t (*)(wrap_nvmlDevice_t, char *, unsigned int))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetUUID");
nvmlh->nvmlDeviceGetVbiosVersion = (wrap_nvmlReturn_t (*)(wrap_nvmlDevice_t, char *, unsigned int))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetVbiosVersion");
nvmlh->nvmlSystemGetDriverVersion = (wrap_nvmlReturn_t (*)(char *, unsigned int))
wrap_dlsym(nvmlh->nvml_dll, "nvmlSystemGetDriverVersion");
nvmlh->nvmlErrorString = (char* (*)(wrap_nvmlReturn_t))
@ -330,6 +332,36 @@ int wrap_nvml_get_busid(wrap_nvml_handle *nvmlh, int cudaindex, int *busid) @@ -330,6 +332,36 @@ int wrap_nvml_get_busid(wrap_nvml_handle *nvmlh, int cudaindex, int *busid)
return 0;
}
int wrap_nvml_get_desc(wrap_nvml_handle *nvmlh, int cudaindex, char *desc, int maxlen)
{
uint32_t subids = 0;
int gpuindex = nvmlh->cuda_nvml_device_id[cudaindex];
if (gpuindex < 0 || gpuindex >= nvmlh->nvml_gpucount)
return -1;
#if 0
// todo: check if there is vendor id is inside
// nvmlDeviceGetUUID: GPU-f2bd642c-369f-5a14-e0b4-0d22dfe9a1fc
wrap_nvmlReturn_t res = nvmlh->nvmlDeviceGetUUID(nvmlh->devs[gpuindex], desc, maxlen);
if (res != WRAPNVML_SUCCESS) {
if (opt_debug)
applog(LOG_DEBUG, "nvmlDeviceGetUUID: %s", nvmlh->nvmlErrorString(res));
} else {
applog(LOG_DEBUG, "nvml Device UUID: %s", desc);
}
#endif
wrap_nvmlReturn_t res = nvmlh->nvmlDeviceGetVbiosVersion(nvmlh->devs[gpuindex], desc, maxlen);
if (res != WRAPNVML_SUCCESS) {
if (opt_debug)
applog(LOG_DEBUG, "nvmlDeviceGetVbiosVersion: %s", nvmlh->nvmlErrorString(res));
return -1;
}
applog(LOG_DEBUG, "nvmlDeviceGetVbiosVersion: %s", desc);
return 0;
}
int wrap_nvml_get_info(wrap_nvml_handle *nvmlh, int cudaindex, uint16_t *vid, uint16_t *pid)
{
uint32_t subids = 0;
@ -491,6 +523,26 @@ int nvapi_getinfo(unsigned int devNum, uint16_t *vid, uint16_t *pid) @@ -491,6 +523,26 @@ int nvapi_getinfo(unsigned int devNum, uint16_t *vid, uint16_t *pid)
return 0;
}
int nvapi_getdesc(unsigned int devNum, char *desc, unsigned int maxlen)
{
NvAPI_Status ret;
if (devNum >= nvapi_dev_cnt)
return -1;
if (maxlen < 64) // Short String
return -1;
ret = NvAPI_GPU_GetVbiosVersionString(phys[devNum], desc);
if (ret != NVAPI_OK) {
NvAPI_ShortString string;
NvAPI_GetErrorMessage(ret, string);
if (opt_debug)
applog(LOG_DEBUG, "NVAPI GetVbiosVersionString: %s", string);
return -1;
}
return 0;
}
int wrap_nvapi_init()
{
int num_gpus = cuda_num_devices();
@ -655,9 +707,11 @@ int gpu_info(struct cgpu_info *gpu) @@ -655,9 +707,11 @@ int gpu_info(struct cgpu_info *gpu)
{
if (hnvml) {
wrap_nvml_get_info(hnvml, gpu->gpu_id, &gpu->gpu_vid, &gpu->gpu_pid);
wrap_nvml_get_desc(hnvml, gpu->gpu_id, gpu->gpu_desc, sizeof(gpu->gpu_desc));
}
#ifdef WIN32
nvapi_getinfo(nvapi_dev_map[gpu->gpu_id], &gpu->gpu_vid, &gpu->gpu_pid);
nvapi_getdesc(nvapi_dev_map[gpu->gpu_id], gpu->gpu_desc, sizeof(gpu->gpu_desc));
#endif
return 0;
}

2
nvml.h

@ -71,6 +71,8 @@ typedef struct { @@ -71,6 +71,8 @@ typedef struct {
wrap_nvmlReturn_t (*nvmlDeviceGetFanSpeed)(wrap_nvmlDevice_t, unsigned int *);
wrap_nvmlReturn_t (*nvmlDeviceGetPerformanceState)(wrap_nvmlDevice_t, int *); /* enum */
wrap_nvmlReturn_t (*nvmlDeviceGetPowerUsage)(wrap_nvmlDevice_t, unsigned int *);
wrap_nvmlReturn_t (*nvmlDeviceGetUUID)(wrap_nvmlDevice_t, char *uuid, unsigned int len);
wrap_nvmlReturn_t (*nvmlDeviceGetVbiosVersion)(wrap_nvmlDevice_t, char *version, unsigned int len);
wrap_nvmlReturn_t (*nvmlSystemGetDriverVersion)(char *version, unsigned int len);
char* (*nvmlErrorString)(wrap_nvmlReturn_t);
wrap_nvmlReturn_t (*nvmlShutdown)(void);

Loading…
Cancel
Save