1
0
mirror of https://github.com/GOSTSec/ccminer synced 2025-01-28 23:44:29 +00:00

linux: reset modified application clocks

This commit is contained in:
Tanguy Pruvot 2015-05-27 15:48:48 +02:00
parent c9d110e543
commit a08056ed2a
3 changed files with 40 additions and 5 deletions

View File

@ -555,8 +555,12 @@ void proper_exit(int reason)
timeEndPeriod(1); // else never executed
#endif
#ifdef USE_WRAPNVML
if (hnvml)
if (hnvml) {
for (int n=0; n < opt_n_threads; n++) {
nvml_reset_clocks(hnvml, device_map[n]);
}
nvml_destroy(hnvml);
}
#endif
free(opt_syslog_pfx);
free(opt_api_allow);

View File

@ -276,13 +276,12 @@ int nvml_set_clocks(nvml_handle *nvmlh, int dev_id)
return -1;
}
if (opt_debug)
applog(LOG_DEBUG, "GPU #%d: NVML application clock feature is allowed", c);
nvmlh->nvmlDeviceGetDefaultApplicationsClock(nvmlh->devs[n], NVML_CLOCK_MEM, &mem_clk);
rc = nvmlh->nvmlDeviceGetDefaultApplicationsClock(nvmlh->devs[n], NVML_CLOCK_GRAPHICS, &gpu_clk);
if (rc != NVML_SUCCESS)
if (rc != NVML_SUCCESS) {
applog(LOG_WARNING, "GPU #%d: unable to query application clocks", c);
return -1;
}
if (opt_debug)
applog(LOG_DEBUG, "GPU #%d: default clocks are %u/%u", c, mem_clk, gpu_clk);
@ -303,6 +302,37 @@ int nvml_set_clocks(nvml_handle *nvmlh, int dev_id)
return 0;
}
/* reset default app clocks to an used device */
int nvml_reset_clocks(nvml_handle *nvmlh, int dev_id)
{
nvmlReturn_t rc;
uint32_t gpu_clk = 0, mem_clk = 0;
int n = nvmlh->cuda_nvml_device_id[dev_id];
if (n < 0 || n >= nvmlh->nvml_gpucount)
return -1;
if (!gpu_clocks_changed[dev_id])
return 0; // nothing to do
int c = nvmlh->nvml_cuda_device_id[n];
nvmlh->nvmlDeviceGetDefaultApplicationsClock(nvmlh->devs[n], NVML_CLOCK_MEM, &mem_clk);
rc = nvmlh->nvmlDeviceGetDefaultApplicationsClock(nvmlh->devs[n], NVML_CLOCK_GRAPHICS, &gpu_clk);
if (rc != NVML_SUCCESS) {
applog(LOG_WARNING, "GPU #%d: unable to query application clocks", c);
return -1;
}
rc = nvmlh->nvmlDeviceSetApplicationsClocks(nvmlh->devs[n], mem_clk, gpu_clk);
if (rc == NVML_SUCCESS)
applog(LOG_INFO, "GPU #%d: application clocks reset to %u/%u", c, mem_clk, gpu_clk);
else {
applog(LOG_ERR, "GPU #%d: %u/%u - %s", c, mem_clk, gpu_clk, nvmlh->nvmlErrorString(rc));
return -1;
}
gpu_clocks_changed[dev_id] = 0;
}
int nvml_get_gpucount(nvml_handle *nvmlh, int *gpucount)
{
*gpucount = nvmlh->nvml_gpucount;

1
nvml.h
View File

@ -157,6 +157,7 @@ int nvml_get_power_usage(nvml_handle *nvmlh,
unsigned int *milliwatts);
int nvml_set_clocks(nvml_handle *nvmlh, int dev_id);
int nvml_reset_clocks(nvml_handle *nvmlh, int dev_id);
/* api functions */