Browse Source

nvml: check available memory clocks and fix param for -d 1

"-d 1 --gpu-clock 1200" was not working
master
Tanguy Pruvot 10 years ago
parent
commit
0c545eb724
  1. 18
      ccminer.cpp
  2. 32
      nvml.cpp
  3. 3
      nvml.h

18
ccminer.cpp

@ -2911,25 +2911,23 @@ void parse_arg(int key, char *arg)
case 1070: /* --gpu-clock */ case 1070: /* --gpu-clock */
{ {
char *pch = strtok(arg,","); char *pch = strtok(arg,",");
int n = 0, last = atoi(arg); int n = 0;
while (pch != NULL) { while (pch != NULL && n < MAX_GPUS) {
device_gpu_clocks[n++] = last = atoi(pch); int dev_id = device_map[n++];
device_gpu_clocks[dev_id] = atoi(pch);
pch = strtok(NULL, ","); pch = strtok(NULL, ",");
} }
//while (n < MAX_GPUS)
// device_gpu_clocks[n++] = last;
} }
break; break;
case 1071: /* --mem-clock */ case 1071: /* --mem-clock */
{ {
char *pch = strtok(arg,","); char *pch = strtok(arg,",");
int n = 0, last = atoi(arg); int n = 0;
while (pch != NULL) { while (pch != NULL && n < MAX_GPUS) {
device_mem_clocks[n++] = last = atoi(pch); int dev_id = device_map[n++];
device_mem_clocks[dev_id] = atoi(pch);
pch = strtok(NULL, ","); pch = strtok(NULL, ",");
} }
//while (n < MAX_GPUS)
// device_gpu_clocks[n++] = last;
} }
break; break;
case 1005: case 1005:

32
nvml.cpp

@ -137,6 +137,13 @@ nvml_handle * nvml_create()
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceResetApplicationsClocks"); wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceResetApplicationsClocks");
nvmlh->nvmlDeviceGetSupportedGraphicsClocks = (nvmlReturn_t (*)(nvmlDevice_t, uint32_t mem, uint32_t *num, uint32_t *)) nvmlh->nvmlDeviceGetSupportedGraphicsClocks = (nvmlReturn_t (*)(nvmlDevice_t, uint32_t mem, uint32_t *num, uint32_t *))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetSupportedGraphicsClocks"); wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetSupportedGraphicsClocks");
nvmlh->nvmlDeviceGetSupportedMemoryClocks = (nvmlReturn_t (*)(nvmlDevice_t, unsigned int *count, unsigned int *clocksMHz))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetSupportedMemoryClocks");
/* NVML_ERROR_NOT_SUPPORTED
nvmlh->nvmlDeviceGetAutoBoostedClocksEnabled = (nvmlReturn_t (*)(nvmlDevice_t, nvmlEnableState_t *isEnabled, nvmlEnableState_t *defaultIsEnabled))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetAutoBoostedClocksEnabled");
nvmlh->nvmlDeviceSetAutoBoostedClocksEnabled = (nvmlReturn_t (*)(nvmlDevice_t, nvmlEnableState_t enabled))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceSetAutoBoostedClocksEnabled"); */
nvmlh->nvmlDeviceGetClockInfo = (nvmlReturn_t (*)(nvmlDevice_t, nvmlClockType_t, unsigned int *clock)) nvmlh->nvmlDeviceGetClockInfo = (nvmlReturn_t (*)(nvmlDevice_t, nvmlClockType_t, unsigned int *clock))
wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetClockInfo"); wrap_dlsym(nvmlh->nvml_dll, "nvmlDeviceGetClockInfo");
nvmlh->nvmlDeviceGetPciInfo = (nvmlReturn_t (*)(nvmlDevice_t, nvmlPciInfo_t *)) nvmlh->nvmlDeviceGetPciInfo = (nvmlReturn_t (*)(nvmlDevice_t, nvmlPciInfo_t *))
@ -162,6 +169,14 @@ nvml_handle * nvml_create()
nvmlh->nvmlShutdown = (nvmlReturn_t (*)()) nvmlh->nvmlShutdown = (nvmlReturn_t (*)())
wrap_dlsym(nvmlh->nvml_dll, "nvmlShutdown"); wrap_dlsym(nvmlh->nvml_dll, "nvmlShutdown");
/*
nvmlDeviceGetBrand(nvmlDevice_t device, nvmlBrandType_t *type)
nvmlDeviceGetMaxPcieLinkWidth(nvmlDevice_t device, unsigned int *maxLinkWidth)
nvmlDeviceGetMaxPcieLinkGeneration(nvmlDevice_t device, unsigned int *maxLinkGen)
nvmlDeviceGetCurrPcieLinkWidth(nvmlDevice_t device, unsigned int *currLinkWidth)
nvmlDeviceGetCurrPcieLinkGeneration(nvmlDevice_t device, unsigned int *currLinkGen)
*/
if (nvmlh->nvmlInit == NULL || if (nvmlh->nvmlInit == NULL ||
nvmlh->nvmlShutdown == NULL || nvmlh->nvmlShutdown == NULL ||
nvmlh->nvmlErrorString == NULL || nvmlh->nvmlErrorString == NULL ||
@ -293,11 +308,24 @@ int nvml_set_clocks(nvml_handle *nvmlh, int dev_id)
if (device_mem_clocks[dev_id]) mem_clk = device_mem_clocks[dev_id]; if (device_mem_clocks[dev_id]) mem_clk = device_mem_clocks[dev_id];
if (device_gpu_clocks[dev_id]) gpu_clk = device_gpu_clocks[dev_id]; if (device_gpu_clocks[dev_id]) gpu_clk = device_gpu_clocks[dev_id];
uint32_t nclocks, clocks[128] = { 0 }; // these functions works for the 960 and the 970 (346.72+), not for the 750 Ti
uint32_t nclocks = 0, clocks[128] = { 0 };
nvmlh->nvmlDeviceGetSupportedMemoryClocks(nvmlh->devs[n], &nclocks, NULL);
nclocks = min(nclocks, 128);
nvmlh->nvmlDeviceGetSupportedMemoryClocks(nvmlh->devs[n], &nclocks, clocks);
for (uint8_t u=0; u < nclocks; u++) {
// ordered desc, so get first
if (clocks[u] <= mem_clk) {
mem_clk = clocks[u];
break;
}
}
nclocks = 0;
nvmlh->nvmlDeviceGetSupportedGraphicsClocks(nvmlh->devs[n], mem_clk, &nclocks, NULL); nvmlh->nvmlDeviceGetSupportedGraphicsClocks(nvmlh->devs[n], mem_clk, &nclocks, NULL);
nclocks = min(nclocks, 128); nclocks = min(nclocks, 128);
nvmlh->nvmlDeviceGetSupportedGraphicsClocks(nvmlh->devs[n], mem_clk, &nclocks, clocks); nvmlh->nvmlDeviceGetSupportedGraphicsClocks(nvmlh->devs[n], mem_clk, &nclocks, clocks);
for (unsigned int u=0; u < nclocks; u++) { for (uint8_t u=0; u < nclocks; u++) {
// ordered desc, so get first // ordered desc, so get first
if (clocks[u] <= gpu_clk) { if (clocks[u] <= gpu_clk) {
gpu_clk = clocks[u]; gpu_clk = clocks[u];

3
nvml.h

@ -96,6 +96,9 @@ typedef struct {
nvmlReturn_t (*nvmlDeviceSetApplicationsClocks)(nvmlDevice_t, unsigned int, unsigned int); nvmlReturn_t (*nvmlDeviceSetApplicationsClocks)(nvmlDevice_t, unsigned int, unsigned int);
nvmlReturn_t (*nvmlDeviceResetApplicationsClocks)(nvmlDevice_t); nvmlReturn_t (*nvmlDeviceResetApplicationsClocks)(nvmlDevice_t);
nvmlReturn_t (*nvmlDeviceGetSupportedGraphicsClocks)(nvmlDevice_t, uint32_t mem, uint32_t *num, uint32_t *arr); nvmlReturn_t (*nvmlDeviceGetSupportedGraphicsClocks)(nvmlDevice_t, uint32_t mem, uint32_t *num, uint32_t *arr);
nvmlReturn_t (*nvmlDeviceGetSupportedMemoryClocks)(nvmlDevice_t, unsigned int *count, unsigned int *clocksMHz);
nvmlReturn_t (*nvmlDeviceGetAutoBoostedClocksEnabled)(nvmlDevice_t, nvmlEnableState_t *isEnabled, nvmlEnableState_t *defaultIsEnabled);
nvmlReturn_t (*nvmlDeviceSetAutoBoostedClocksEnabled)(nvmlDevice_t, nvmlEnableState_t enabled);
nvmlReturn_t (*nvmlDeviceGetClockInfo)(nvmlDevice_t, nvmlClockType_t, unsigned int *); nvmlReturn_t (*nvmlDeviceGetClockInfo)(nvmlDevice_t, nvmlClockType_t, unsigned int *);
nvmlReturn_t (*nvmlDeviceGetPciInfo)(nvmlDevice_t, nvmlPciInfo_t *); nvmlReturn_t (*nvmlDeviceGetPciInfo)(nvmlDevice_t, nvmlPciInfo_t *);
nvmlReturn_t (*nvmlDeviceGetName)(nvmlDevice_t, char *, int); nvmlReturn_t (*nvmlDeviceGetName)(nvmlDevice_t, char *, int);

Loading…
Cancel
Save