1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 09:58:16 +00:00

Replace "#if defined (HAVE_HWMON)" with "user_options->powertune_enable = false" which give a more easy to read sourcecode

This commit is contained in:
jsteube 2016-09-22 10:55:33 +02:00
parent 458d6b37f9
commit 2215174c2e
8 changed files with 59 additions and 102 deletions

View File

@ -802,11 +802,9 @@ typedef struct
u32 kernel_loops; u32 kernel_loops;
u32 nvidia_spin_damp; u32 nvidia_spin_damp;
bool gpu_temp_disable; bool gpu_temp_disable;
#if defined (HAVE_HWMON)
u32 gpu_temp_abort; u32 gpu_temp_abort;
u32 gpu_temp_retain; u32 gpu_temp_retain;
bool powertune_enable; bool powertune_enable;
#endif
bool logfile_disable; bool logfile_disable;
u32 segment_size; u32 segment_size;
u32 scrypt_tmto; u32 scrypt_tmto;
@ -940,13 +938,11 @@ typedef struct
* hardware watchdog * hardware watchdog
*/ */
#if defined (HAVE_HWMON)
void *hm_adl; void *hm_adl;
void *hm_nvml; void *hm_nvml;
void *hm_nvapi; void *hm_nvapi;
void *hm_xnvctrl; void *hm_xnvctrl;
hm_attrs_t hm_device[DEVICES_MAX]; hm_attrs_t hm_device[DEVICES_MAX];
#endif
/** /**
* logging * logging
@ -1028,11 +1024,9 @@ typedef struct
debugfile_ctx_t *debugfile_ctx; debugfile_ctx_t *debugfile_ctx;
session_ctx_t *session_ctx; session_ctx_t *session_ctx;
#if defined (HAVE_HWMON)
u32 gpu_temp_disable; u32 gpu_temp_disable;
u32 gpu_temp_abort; u32 gpu_temp_abort;
u32 gpu_temp_retain; u32 gpu_temp_retain;
#endif
char **rp_files; char **rp_files;
u32 rp_files_cnt; u32 rp_files_cnt;

View File

@ -220,11 +220,9 @@ static const struct option long_options[] =
{"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS}, {"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS},
{"nvidia-spin-damp", required_argument, 0, IDX_NVIDIA_SPIN_DAMP}, {"nvidia-spin-damp", required_argument, 0, IDX_NVIDIA_SPIN_DAMP},
{"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE}, {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
#if defined (HAVE_HWMON)
{"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT}, {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
{"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN}, {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
{"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE}, {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
#endif // HAVE_HWMON
{"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE}, {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
{"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES}, {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
{"veracrypt-keyfiles", required_argument, 0, IDX_VERACRYPT_KEYFILES}, {"veracrypt-keyfiles", required_argument, 0, IDX_VERACRYPT_KEYFILES},

View File

@ -561,9 +561,7 @@ int main (int argc, char **argv)
logfile_top_uint (user_options->outfile_format); logfile_top_uint (user_options->outfile_format);
logfile_top_uint (user_options->potfile_disable); logfile_top_uint (user_options->potfile_disable);
logfile_top_string (user_options->potfile_path); logfile_top_string (user_options->potfile_path);
#if defined(HAVE_HWMON)
logfile_top_uint (user_options->powertune_enable); logfile_top_uint (user_options->powertune_enable);
#endif
logfile_top_uint (user_options->scrypt_tmto); logfile_top_uint (user_options->scrypt_tmto);
logfile_top_uint (user_options->quiet); logfile_top_uint (user_options->quiet);
logfile_top_uint (user_options->remove); logfile_top_uint (user_options->remove);
@ -1251,7 +1249,6 @@ int main (int argc, char **argv)
* HM devices: init * HM devices: init
*/ */
#if defined (HAVE_HWMON)
hm_attrs_t hm_adapters_adl[DEVICES_MAX]; hm_attrs_t hm_adapters_adl[DEVICES_MAX];
hm_attrs_t hm_adapters_nvapi[DEVICES_MAX]; hm_attrs_t hm_adapters_nvapi[DEVICES_MAX];
hm_attrs_t hm_adapters_nvml[DEVICES_MAX]; hm_attrs_t hm_adapters_nvml[DEVICES_MAX];
@ -1428,7 +1425,6 @@ int main (int argc, char **argv)
data.gpu_temp_disable = user_options->gpu_temp_disable; data.gpu_temp_disable = user_options->gpu_temp_disable;
data.gpu_temp_abort = user_options->gpu_temp_abort; data.gpu_temp_abort = user_options->gpu_temp_abort;
data.gpu_temp_retain = user_options->gpu_temp_retain; data.gpu_temp_retain = user_options->gpu_temp_retain;
#endif
/** /**
* enable custom signal handler(s) * enable custom signal handler(s)
@ -1474,7 +1470,6 @@ int main (int argc, char **argv)
* Watchdog and Temperature balance * Watchdog and Temperature balance
*/ */
#if defined (HAVE_HWMON)
if (user_options->gpu_temp_disable == false && data.hm_adl == NULL && data.hm_nvml == NULL && data.hm_xnvctrl == NULL) if (user_options->gpu_temp_disable == false && data.hm_adl == NULL && data.hm_nvml == NULL && data.hm_xnvctrl == NULL)
{ {
log_info ("Watchdog: Hardware Monitoring Interface not found on your system"); log_info ("Watchdog: Hardware Monitoring Interface not found on your system");
@ -1499,11 +1494,8 @@ int main (int argc, char **argv)
} }
if (user_options->quiet == false) log_info (""); if (user_options->quiet == false) log_info ("");
#endif
} }
#if defined (HAVE_HWMON)
/** /**
* HM devices: copy * HM devices: copy
*/ */
@ -1737,8 +1729,6 @@ int main (int argc, char **argv)
hc_thread_mutex_unlock (mux_hwmon); hc_thread_mutex_unlock (mux_hwmon);
} }
#endif // HAVE_HWMON
#if defined (DEBUG) #if defined (DEBUG)
if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode); if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode);
#endif #endif
@ -1759,71 +1749,69 @@ int main (int argc, char **argv)
* Store initial fanspeed if gpu_temp_retain is enabled * Store initial fanspeed if gpu_temp_retain is enabled
*/ */
#if defined(HAVE_HWMON) if (user_options->gpu_temp_disable == false)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{ {
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; if (user_options->gpu_temp_retain)
if (device_param->skipped) continue;
if (user_options->gpu_temp_disable == true) continue;
if (user_options->gpu_temp_retain == 0) continue;
hc_thread_mutex_lock (mux_hwmon);
if (data.hm_device[device_id].fan_get_supported == 1)
{ {
const int fanspeed = hm_get_fanspeed_with_device_id (opencl_ctx, device_id); for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
const int fanpolicy = hm_get_fanpolicy_with_device_id (opencl_ctx, device_id);
// we also set it to tell the OS we take control over the fan and it's automatic controller
// if it was set to automatic. we do not control user-defined fanspeeds.
if (fanpolicy == 1)
{ {
data.hm_device[device_id].fan_set_supported = 1; hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
int rc = -1; if (device_param->skipped) continue;
if (device_param->device_vendor_id == VENDOR_ID_AMD) hc_thread_mutex_lock (mux_hwmon);
if (data.hm_device[device_id].fan_get_supported == 1)
{ {
rc = hm_set_fanspeed_with_device_id_adl (device_id, fanspeed, 1); const int fanspeed = hm_get_fanspeed_with_device_id (opencl_ctx, device_id);
} const int fanpolicy = hm_get_fanpolicy_with_device_id (opencl_ctx, device_id);
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
#if defined (__linux__)
rc = set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE);
#endif
#if defined (_WIN) // we also set it to tell the OS we take control over the fan and it's automatic controller
rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, 1); // if it was set to automatic. we do not control user-defined fanspeeds.
#endif
if (fanpolicy == 1)
{
data.hm_device[device_id].fan_set_supported = 1;
int rc = -1;
if (device_param->device_vendor_id == VENDOR_ID_AMD)
{
rc = hm_set_fanspeed_with_device_id_adl (device_id, fanspeed, 1);
}
else if (device_param->device_vendor_id == VENDOR_ID_NV)
{
#if defined (__linux__)
rc = set_fan_control (data.hm_xnvctrl, data.hm_device[device_id].xnvctrl, NV_CTRL_GPU_COOLER_MANUAL_CONTROL_TRUE);
#endif
#if defined (_WIN)
rc = hm_set_fanspeed_with_device_id_nvapi (device_id, fanspeed, 1);
#endif
}
if (rc == 0)
{
data.hm_device[device_id].fan_set_supported = 1;
}
else
{
log_info ("WARNING: Failed to set initial fan speed for device #%u", device_id + 1);
data.hm_device[device_id].fan_set_supported = 0;
}
}
else
{
data.hm_device[device_id].fan_set_supported = 0;
}
} }
if (rc == 0) hc_thread_mutex_unlock (mux_hwmon);
{
data.hm_device[device_id].fan_set_supported = 1;
}
else
{
log_info ("WARNING: Failed to set initial fan speed for device #%u", device_id + 1);
data.hm_device[device_id].fan_set_supported = 0;
}
}
else
{
data.hm_device[device_id].fan_set_supported = 0;
} }
} }
hc_thread_mutex_unlock (mux_hwmon);
} }
#endif // HAVE_HWMON
/** /**
* In benchmark-mode, inform user which algorithm is checked * In benchmark-mode, inform user which algorithm is checked
*/ */
@ -3906,10 +3894,9 @@ int main (int argc, char **argv)
// reset default fan speed // reset default fan speed
#if defined (HAVE_HWMON)
if (user_options->gpu_temp_disable == false) if (user_options->gpu_temp_disable == false)
{ {
if (user_options->gpu_temp_retain != 0) if (user_options->gpu_temp_retain)
{ {
hc_thread_mutex_lock (mux_hwmon); hc_thread_mutex_lock (mux_hwmon);
@ -4059,7 +4046,6 @@ int main (int argc, char **argv)
data.hm_adl = NULL; data.hm_adl = NULL;
} }
} }
#endif // HAVE_HWMON
if (opencl_ctx->run_main_level1 == false) break; if (opencl_ctx->run_main_level1 == false) break;
@ -4098,11 +4084,9 @@ int main (int argc, char **argv)
local_free (bitmap_s2_c); local_free (bitmap_s2_c);
local_free (bitmap_s2_d); local_free (bitmap_s2_d);
#if defined (HAVE_HWMON)
local_free (od_clock_mem_status); local_free (od_clock_mem_status);
local_free (od_power_control_status); local_free (od_power_control_status);
local_free (nvml_power_limit); local_free (nvml_power_limit);
#endif
global_free (kernel_rules_buf); global_free (kernel_rules_buf);

View File

@ -30,8 +30,6 @@
hc_thread_mutex_t mux_hwmon; hc_thread_mutex_t mux_hwmon;
#if defined (HAVE_HWMON)
extern hc_global_data_t data; extern hc_global_data_t data;
int get_adapters_num_adl (void *adl, int *iNumberAdapters) int get_adapters_num_adl (void *adl, int *iNumberAdapters)
@ -871,5 +869,3 @@ int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fans
return -1; return -1;
} }
#endif // HAVE_HWMON

View File

@ -52,7 +52,6 @@ void *thread_monitor (void *p)
hashconfig_t *hashconfig = data.hashconfig; hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes; hashes_t *hashes = data.hashes;
#if defined (HAVE_HWMON)
uint hwmon_check = 0; uint hwmon_check = 0;
int slowdown_warnings = 0; int slowdown_warnings = 0;
@ -72,7 +71,6 @@ void *thread_monitor (void *p)
int fan_speed_max = 100; int fan_speed_max = 100;
time_t last_temp_check_time; time_t last_temp_check_time;
#endif // HAVE_HWMON
uint sleep_time = 1; uint sleep_time = 1;
@ -96,20 +94,17 @@ void *thread_monitor (void *p)
status_check = 1; status_check = 1;
} }
#if defined (HAVE_HWMON)
if (data.gpu_temp_disable == 0) if (data.gpu_temp_disable == 0)
{ {
time (&last_temp_check_time); time (&last_temp_check_time);
hwmon_check = 1; hwmon_check = 1;
} }
#endif
if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (restore_check == 0)) if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (restore_check == 0))
{ {
#if defined (HAVE_HWMON)
if (hwmon_check == 0) if (hwmon_check == 0)
#endif
return (p); return (p);
} }
@ -119,8 +114,6 @@ void *thread_monitor (void *p)
if (opencl_ctx->devices_status == STATUS_INIT) continue; if (opencl_ctx->devices_status == STATUS_INIT) continue;
#if defined (HAVE_HWMON)
if (hwmon_check == 1) if (hwmon_check == 1)
{ {
hc_thread_mutex_lock (mux_hwmon); hc_thread_mutex_lock (mux_hwmon);
@ -281,7 +274,6 @@ void *thread_monitor (void *p)
hc_thread_mutex_unlock (mux_hwmon); hc_thread_mutex_unlock (mux_hwmon);
} }
#endif // HAVE_HWMON
if (restore_check == 1) if (restore_check == 1)
{ {
@ -365,12 +357,10 @@ void *thread_monitor (void *p)
} }
} }
#if defined (HAVE_HWMON)
myfree (fan_speed_chgd); myfree (fan_speed_chgd);
myfree (temp_diff_old); myfree (temp_diff_old);
myfree (temp_diff_sum); myfree (temp_diff_sum);
#endif
p = NULL; p = NULL;

View File

@ -258,7 +258,6 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
* temperature * temperature
*/ */
#if defined (HAVE_HWMON)
if (data.gpu_temp_disable == 0) if (data.gpu_temp_disable == 0)
{ {
fprintf (out, "TEMP\t"); fprintf (out, "TEMP\t");
@ -278,7 +277,6 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
hc_thread_mutex_unlock (mux_hwmon); hc_thread_mutex_unlock (mux_hwmon);
} }
#endif // HAVE_HWMON
/** /**
* flush * flush
@ -1031,8 +1029,6 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
} }
} }
#if defined (HAVE_HWMON)
if (opencl_ctx->run_main_level1 == false) return; if (opencl_ctx->run_main_level1 == false) return;
if (data.gpu_temp_disable == 0) if (data.gpu_temp_disable == 0)
@ -1118,8 +1114,6 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
hc_thread_mutex_unlock (mux_hwmon); hc_thread_mutex_unlock (mux_hwmon);
} }
#endif // HAVE_HWMON
} }
void status_benchmark_automate (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig) void status_benchmark_automate (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig)

View File

@ -83,11 +83,9 @@ static const char *USAGE_BIG[] =
" -u, --kernel-loops | Num | Manual workload tuning, set innerloop step size to X | -u 256", " -u, --kernel-loops | Num | Manual workload tuning, set innerloop step size to X | -u 256",
" --nvidia-spin-damp | Num | Workaround NVidias CPU burning loop bug, in percent | --nvidia-spin-damp=50", " --nvidia-spin-damp | Num | Workaround NVidias CPU burning loop bug, in percent | --nvidia-spin-damp=50",
" --gpu-temp-disable | | Disable temperature and fanspeed reads and triggers |", " --gpu-temp-disable | | Disable temperature and fanspeed reads and triggers |",
#if defined (HAVE_HWMON)
" --gpu-temp-abort | Num | Abort if GPU temperature reaches X degrees celsius | --gpu-temp-abort=100", " --gpu-temp-abort | Num | Abort if GPU temperature reaches X degrees celsius | --gpu-temp-abort=100",
" --gpu-temp-retain | Num | Try to retain GPU temperature at X degrees celsius | --gpu-temp-retain=95", " --gpu-temp-retain | Num | Try to retain GPU temperature at X degrees celsius | --gpu-temp-retain=95",
" --powertune-enable | | Enable power tuning, restores settings when finished |", " --powertune-enable | | Enable power tuning, restores settings when finished |",
#endif
" --scrypt-tmto | Num | Manually override TMTO value for scrypt to X | --scrypt-tmto=3", " --scrypt-tmto | Num | Manually override TMTO value for scrypt to X | --scrypt-tmto=3",
" -s, --skip | Num | Skip X words from the start | -s 1000000", " -s, --skip | Num | Skip X words from the start | -s 1000000",
" -l, --limit | Num | Limit X words from the start + skipped words | -l 1000000", " -l, --limit | Num | Limit X words from the start + skipped words | -l 1000000",

View File

@ -193,11 +193,9 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
case IDX_NVIDIA_SPIN_DAMP: user_options->nvidia_spin_damp = atoi (optarg); case IDX_NVIDIA_SPIN_DAMP: user_options->nvidia_spin_damp = atoi (optarg);
user_options->nvidia_spin_damp_chgd = true; break; user_options->nvidia_spin_damp_chgd = true; break;
case IDX_GPU_TEMP_DISABLE: user_options->gpu_temp_disable = true; break; case IDX_GPU_TEMP_DISABLE: user_options->gpu_temp_disable = true; break;
#if defined (HAVE_HWMON)
case IDX_GPU_TEMP_ABORT: user_options->gpu_temp_abort = atoi (optarg); break; case IDX_GPU_TEMP_ABORT: user_options->gpu_temp_abort = atoi (optarg); break;
case IDX_GPU_TEMP_RETAIN: user_options->gpu_temp_retain = atoi (optarg); break; case IDX_GPU_TEMP_RETAIN: user_options->gpu_temp_retain = atoi (optarg); break;
case IDX_POWERTUNE_ENABLE: user_options->powertune_enable = true; break; case IDX_POWERTUNE_ENABLE: user_options->powertune_enable = true; break;
#endif // HAVE_HWMON
case IDX_LOGFILE_DISABLE: user_options->logfile_disable = true; break; case IDX_LOGFILE_DISABLE: user_options->logfile_disable = true; break;
case IDX_TRUECRYPT_KEYFILES: user_options->truecrypt_keyfiles = optarg; break; case IDX_TRUECRYPT_KEYFILES: user_options->truecrypt_keyfiles = optarg; break;
case IDX_VERACRYPT_KEYFILES: user_options->veracrypt_keyfiles = optarg; break; case IDX_VERACRYPT_KEYFILES: user_options->veracrypt_keyfiles = optarg; break;
@ -234,6 +232,13 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
return -1; return -1;
} }
#if !defined (HAVE_HWMON)
user_options->powertune_enable = false;
user_options->gpu_temp_disable = true;
user_options->gpu_temp_abort = 0;
user_options->gpu_temp_retain = 0;
#endif // HAVE_HWMON
// some options can influence or overwrite other options // some options can influence or overwrite other options
if (user_options->opencl_info == true if (user_options->opencl_info == true
@ -268,12 +273,10 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
user_options->workload_profile = 3; user_options->workload_profile = 3;
} }
#if defined (HAVE_HWMON)
if (user_options->powertune_enable == true) if (user_options->powertune_enable == true)
{ {
user_options->gpu_temp_disable = false; user_options->gpu_temp_disable = false;
} }
#endif
} }
if (user_options->keyspace == true) if (user_options->keyspace == true)