mirror of
https://github.com/hashcat/hashcat.git
synced 2025-01-05 13:21:13 +00:00
Send a notice to user in case the drivers temperature threshold for slowdown is reached and a performance drop is expected due to throttling
This commit is contained in:
parent
f91dc3ac80
commit
3e4badd9b4
@ -58,6 +58,15 @@ typedef enum nvmlClockType_enum {
|
|||||||
NVML_CLOCK_MEM = 2
|
NVML_CLOCK_MEM = 2
|
||||||
} nvmlClockType_t;
|
} nvmlClockType_t;
|
||||||
|
|
||||||
|
typedef enum nvmlTemperatureThresholds_enum
|
||||||
|
{
|
||||||
|
NVML_TEMPERATURE_THRESHOLD_SHUTDOWN = 0, // Temperature at which the GPU will shut down
|
||||||
|
// for HW protection
|
||||||
|
NVML_TEMPERATURE_THRESHOLD_SLOWDOWN = 1, // Temperature at which the GPU will begin slowdown
|
||||||
|
// Keep this last
|
||||||
|
NVML_TEMPERATURE_THRESHOLD_COUNT
|
||||||
|
} nvmlTemperatureThresholds_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of declarations from nvml.h
|
* End of declarations from nvml.h
|
||||||
**/
|
**/
|
||||||
@ -76,6 +85,7 @@ typedef nvmlReturn_t (*NVML_DEVICE_GET_FAN_SPEED) (nvmlDevice_t, unsigned int *)
|
|||||||
typedef nvmlReturn_t (*NVML_DEVICE_GET_POWER_USAGE) (nvmlDevice_t, unsigned int *);
|
typedef nvmlReturn_t (*NVML_DEVICE_GET_POWER_USAGE) (nvmlDevice_t, unsigned int *);
|
||||||
typedef nvmlReturn_t (*NVML_DEVICE_GET_UTILIZATION_RATES) (nvmlDevice_t, nvmlUtilization_t *);
|
typedef nvmlReturn_t (*NVML_DEVICE_GET_UTILIZATION_RATES) (nvmlDevice_t, nvmlUtilization_t *);
|
||||||
typedef nvmlReturn_t (*NVML_DEVICE_GET_CLOCKINFO) (nvmlDevice_t, nvmlClockType_t, unsigned int *);
|
typedef nvmlReturn_t (*NVML_DEVICE_GET_CLOCKINFO) (nvmlDevice_t, nvmlClockType_t, unsigned int *);
|
||||||
|
typedef nvmlReturn_t (*NVML_DEVICE_GET_THRESHOLD) (nvmlDevice_t, nvmlTemperatureThresholds_t, unsigned int *);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -91,6 +101,7 @@ typedef struct
|
|||||||
NVML_DEVICE_GET_POWER_USAGE nvmlDeviceGetPowerUsage;
|
NVML_DEVICE_GET_POWER_USAGE nvmlDeviceGetPowerUsage;
|
||||||
NVML_DEVICE_GET_UTILIZATION_RATES nvmlDeviceGetUtilizationRates;
|
NVML_DEVICE_GET_UTILIZATION_RATES nvmlDeviceGetUtilizationRates;
|
||||||
NVML_DEVICE_GET_CLOCKINFO nvmlDeviceGetClockInfo;
|
NVML_DEVICE_GET_CLOCKINFO nvmlDeviceGetClockInfo;
|
||||||
|
NVML_DEVICE_GET_THRESHOLD nvmlDeviceGetTemperatureThreshold;
|
||||||
|
|
||||||
} hm_nvml_lib_t;
|
} hm_nvml_lib_t;
|
||||||
|
|
||||||
@ -109,6 +120,7 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int, nvmlDevice_t de
|
|||||||
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, nvmlDevice_t device, unsigned int *power);
|
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, nvmlDevice_t device, unsigned int *power);
|
||||||
nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, nvmlDevice_t device, nvmlUtilization_t *utilization);
|
nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, nvmlDevice_t device, nvmlUtilization_t *utilization);
|
||||||
nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock);
|
nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock);
|
||||||
|
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp);
|
||||||
|
|
||||||
#endif // HAVE_HWMON && HAVE_NVML
|
#endif // HAVE_HWMON && HAVE_NVML
|
||||||
|
|
||||||
|
@ -1454,6 +1454,7 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
|
|||||||
// void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices);
|
// void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices);
|
||||||
#endif // HAVE_ADL
|
#endif // HAVE_ADL
|
||||||
|
|
||||||
|
int hm_get_threshold_slowdown_with_device_id (const uint device_id);
|
||||||
int hm_get_temperature_with_device_id (const uint device_id);
|
int hm_get_temperature_with_device_id (const uint device_id);
|
||||||
int hm_get_fanspeed_with_device_id (const uint device_id);
|
int hm_get_fanspeed_with_device_id (const uint device_id);
|
||||||
int hm_get_utilization_with_device_id (const uint device_id);
|
int hm_get_utilization_with_device_id (const uint device_id);
|
||||||
|
@ -1101,6 +1101,9 @@ typedef struct
|
|||||||
int od_version;
|
int od_version;
|
||||||
int fan_supported;
|
int fan_supported;
|
||||||
|
|
||||||
|
int gpu_temp_threshold_slowdown;
|
||||||
|
int gpu_temp_threshold_shutdown;
|
||||||
|
|
||||||
// int busid; // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPUs
|
// int busid; // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPUs
|
||||||
// int devid; // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPUs
|
// int devid; // used for CL_DEVICE_TOPOLOGY_AMD but broken for dual GPUs
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ int nvml_init (NVML_PTR *nvml)
|
|||||||
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerUsage, NVML_DEVICE_GET_POWER_USAGE, NVML, 0)
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerUsage, NVML_DEVICE_GET_POWER_USAGE, NVML, 0)
|
||||||
HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0)
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0)
|
||||||
HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0)
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0)
|
||||||
|
HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -218,3 +219,20 @@ nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, nvmlDevice_t device
|
|||||||
return nvml_rc;
|
return nvml_rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp)
|
||||||
|
{
|
||||||
|
if (!nvml) return -1;
|
||||||
|
|
||||||
|
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp);
|
||||||
|
|
||||||
|
if (nvml_rc != NVML_SUCCESS)
|
||||||
|
{
|
||||||
|
*temp = -1;
|
||||||
|
|
||||||
|
//const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
|
||||||
|
|
||||||
|
//log_info ("WARN: %s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nvml_rc;
|
||||||
|
}
|
||||||
|
@ -2104,6 +2104,7 @@ static void check_hash (hc_device_param_t *device_param, plain_t *plain)
|
|||||||
|
|
||||||
out_fp = stdout;
|
out_fp = stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock_file (out_fp);
|
lock_file (out_fp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3781,6 +3782,8 @@ static void *thread_monitor (void *p)
|
|||||||
#ifdef HAVE_HWMON
|
#ifdef HAVE_HWMON
|
||||||
uint hwmon_check = 0;
|
uint hwmon_check = 0;
|
||||||
|
|
||||||
|
int slowdown_warnings = 0;
|
||||||
|
|
||||||
// these variables are mainly used for fan control (AMD only)
|
// these variables are mainly used for fan control (AMD only)
|
||||||
|
|
||||||
int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
|
int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
|
||||||
@ -3845,8 +3848,52 @@ static void *thread_monitor (void *p)
|
|||||||
|
|
||||||
if (data.devices_status != STATUS_RUNNING) continue;
|
if (data.devices_status != STATUS_RUNNING) continue;
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_HWMON
|
#ifdef HAVE_HWMON
|
||||||
|
|
||||||
|
if (1)
|
||||||
|
{
|
||||||
|
hc_thread_mutex_lock (mux_adl);
|
||||||
|
|
||||||
|
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
|
||||||
|
{
|
||||||
|
hc_device_param_t *device_param = &data.devices_param[device_id];
|
||||||
|
|
||||||
|
if (device_param->skipped) continue;
|
||||||
|
|
||||||
|
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
|
||||||
|
|
||||||
|
const int temperature = hm_get_temperature_with_device_id (device_id);
|
||||||
|
|
||||||
|
const int threshold = data.hm_device[device_id].gpu_temp_threshold_slowdown;
|
||||||
|
|
||||||
|
if (temperature >= threshold)
|
||||||
|
{
|
||||||
|
if (slowdown_warnings < 3)
|
||||||
|
{
|
||||||
|
if (data.quiet == 0) clear_prompt ();
|
||||||
|
|
||||||
|
log_info ("WARNING: Drivers temperature threshold (%dc) hit on GPU #%d, expect performance to drop...", threshold, device_id + 1);
|
||||||
|
|
||||||
|
if (slowdown_warnings == 2)
|
||||||
|
{
|
||||||
|
log_info ("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.quiet == 0) fprintf (stdout, "%s", PROMPT);
|
||||||
|
if (data.quiet == 0) fflush (stdout);
|
||||||
|
|
||||||
|
slowdown_warnings++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slowdown_warnings = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hc_thread_mutex_unlock (mux_adl);
|
||||||
|
}
|
||||||
|
|
||||||
if (hwmon_check == 1)
|
if (hwmon_check == 1)
|
||||||
{
|
{
|
||||||
hc_thread_mutex_lock (mux_adl);
|
hc_thread_mutex_lock (mux_adl);
|
||||||
@ -13946,11 +13993,11 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef HAVE_HWMON
|
#ifdef HAVE_HWMON
|
||||||
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||||
hm_attrs_t hm_adapters_nv[DEVICES_MAX] = { { { 0 }, 0, 0 } };
|
hm_attrs_t hm_adapters_nv[DEVICES_MAX] = { { { 0 }, 0, 0, 0, 0 } };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ADL
|
#ifdef HAVE_ADL
|
||||||
hm_attrs_t hm_adapters_amd[DEVICES_MAX] = { { { 0 }, 0, 0 } };
|
hm_attrs_t hm_adapters_amd[DEVICES_MAX] = { { { 0 }, 0, 0, 0, 0 } };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (gpu_temp_disable == 0)
|
if (gpu_temp_disable == 0)
|
||||||
@ -14219,7 +14266,7 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Temporary fix:
|
* Temporary fix:
|
||||||
* with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
|
* with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
|
||||||
* otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
|
* otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
|
||||||
@ -15565,6 +15612,19 @@ int main (int argc, char **argv)
|
|||||||
run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
|
run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store thermal target temperature so we can send a notice to user
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(HAVE_HWMON)
|
||||||
|
if (gpu_temp_disable == 0)
|
||||||
|
{
|
||||||
|
const int gpu_temp_threshold_slowdown = hm_get_threshold_slowdown_with_device_id (device_id);
|
||||||
|
|
||||||
|
data.hm_device[device_id].gpu_temp_threshold_slowdown = (gpu_temp_threshold_slowdown == -1) ? 100000 : gpu_temp_threshold_slowdown;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store initial fanspeed if gpu_temp_retain is enabled
|
* Store initial fanspeed if gpu_temp_retain is enabled
|
||||||
*/
|
*/
|
||||||
|
29
src/shared.c
29
src/shared.c
@ -3057,6 +3057,34 @@ int hm_get_adapter_index_amd (hm_attrs_t *hm_device, u32 *valid_adl_device_list,
|
|||||||
}
|
}
|
||||||
#endif // HAVE_ADL
|
#endif // HAVE_ADL
|
||||||
|
|
||||||
|
int hm_get_threshold_slowdown_with_device_id (const uint device_id)
|
||||||
|
{
|
||||||
|
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
|
||||||
|
|
||||||
|
#ifdef HAVE_ADL
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_NVML) || defined(HAVE_NVAPI)
|
||||||
|
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
|
||||||
|
{
|
||||||
|
#if defined(LINUX) && defined(HAVE_NVML)
|
||||||
|
int target = 0;
|
||||||
|
|
||||||
|
hm_NVML_nvmlDeviceGetTemperatureThreshold (data.hm_nv, data.hm_device[device_id].adapter_index.nv, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, (unsigned int *) &target);
|
||||||
|
|
||||||
|
return target;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN) && defined(HAVE_NVAPI)
|
||||||
|
|
||||||
|
#endif // WIN && HAVE_NVAPI
|
||||||
|
}
|
||||||
|
#endif // HAVE_NVML || HAVE_NVAPI
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int hm_get_temperature_with_device_id (const uint device_id)
|
int hm_get_temperature_with_device_id (const uint device_id)
|
||||||
{
|
{
|
||||||
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
|
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
|
||||||
@ -3169,7 +3197,6 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WIN) && defined(HAVE_NVAPI)
|
#if defined(WIN) && defined(HAVE_NVAPI)
|
||||||
|
|
||||||
NV_GPU_COOLER_SETTINGS pCoolerSettings;
|
NV_GPU_COOLER_SETTINGS pCoolerSettings;
|
||||||
|
|
||||||
pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS);
|
pCoolerSettings.Version = GPU_COOLER_SETTINGS_VER | sizeof (NV_GPU_COOLER_SETTINGS);
|
||||||
|
Loading…
Reference in New Issue
Block a user