mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-23 00:28:11 +00:00
Move hardware_power_all, kernel_power_all and kernel_power_final to opencl_ctx_t
This commit is contained in:
parent
48917b5843
commit
94680cb311
@ -41,6 +41,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
|
||||
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
|
||||
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
|
||||
void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra);
|
||||
|
||||
int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, const hashes_t *hashes, const straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db);
|
||||
void opencl_session_destroy (opencl_ctx_t *opencl_ctx);
|
||||
|
@ -701,6 +701,11 @@ typedef struct
|
||||
|
||||
hc_device_param_t *devices_param;
|
||||
|
||||
u32 hardware_power_all;
|
||||
|
||||
u32 kernel_power_all;
|
||||
u64 kernel_power_final; // we save that so that all divisions are done from the same base
|
||||
|
||||
bool run_main_level1;
|
||||
bool run_main_level2;
|
||||
bool run_main_level3;
|
||||
@ -1195,14 +1200,6 @@ typedef struct
|
||||
u32 shutdown_inner;
|
||||
u32 shutdown_outer;
|
||||
|
||||
/**
|
||||
* workload specific
|
||||
*/
|
||||
|
||||
u32 hardware_power_all;
|
||||
u32 kernel_power_all;
|
||||
u64 kernel_power_final; // we save that so that all divisions are done from the same base
|
||||
|
||||
/**
|
||||
* hardware watchdog
|
||||
*/
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
static void set_kernel_power_final (const user_options_t *user_options, const u64 kernel_power_final)
|
||||
static void set_kernel_power_final (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const u64 kernel_power_final)
|
||||
{
|
||||
if (user_options->quiet == false)
|
||||
{
|
||||
@ -52,16 +52,16 @@ static void set_kernel_power_final (const user_options_t *user_options, const u6
|
||||
send_prompt ();
|
||||
}
|
||||
|
||||
data.kernel_power_final = kernel_power_final;
|
||||
opencl_ctx->kernel_power_final = kernel_power_final;
|
||||
}
|
||||
|
||||
static u32 get_power (hc_device_param_t *device_param)
|
||||
static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
const u64 kernel_power_final = data.kernel_power_final;
|
||||
const u64 kernel_power_final = opencl_ctx->kernel_power_final;
|
||||
|
||||
if (kernel_power_final)
|
||||
{
|
||||
const double device_factor = (double) device_param->hardware_power / data.hardware_power_all;
|
||||
const double device_factor = (double) device_param->hardware_power / opencl_ctx->hardware_power_all;
|
||||
|
||||
const u64 words_left_device = (u64) CEIL (kernel_power_final * device_factor);
|
||||
|
||||
@ -84,19 +84,19 @@ static uint get_work (opencl_ctx_t *opencl_ctx, const user_options_t *user_optio
|
||||
|
||||
device_param->words_off = words_cur;
|
||||
|
||||
const u64 kernel_power_all = data.kernel_power_all;
|
||||
const u64 kernel_power_all = opencl_ctx->kernel_power_all;
|
||||
|
||||
const u64 words_left = words_base - words_cur;
|
||||
|
||||
if (words_left < kernel_power_all)
|
||||
{
|
||||
if (data.kernel_power_final == 0)
|
||||
if (opencl_ctx->kernel_power_final == 0)
|
||||
{
|
||||
set_kernel_power_final (user_options, words_left);
|
||||
set_kernel_power_final (opencl_ctx, user_options, words_left);
|
||||
}
|
||||
}
|
||||
|
||||
const u32 kernel_power = get_power (device_param);
|
||||
const u32 kernel_power = get_power (opencl_ctx, device_param);
|
||||
|
||||
uint work = MIN (words_left, kernel_power);
|
||||
|
||||
|
@ -1008,8 +1008,6 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
|
||||
|
||||
data.ms_paused = 0;
|
||||
|
||||
data.kernel_power_final = 0;
|
||||
|
||||
opencl_session_reset (opencl_ctx);
|
||||
|
||||
// figure out some workload
|
||||
@ -1278,44 +1276,9 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
|
||||
|
||||
hc_thread_wait (opencl_ctx->devices_cnt, c_threads);
|
||||
|
||||
/*
|
||||
* Inform user about possible slow speeds
|
||||
*/
|
||||
// autotune modified kernel_accel, which modifies opencl_ctx->kernel_power_all
|
||||
|
||||
uint hardware_power_all = 0;
|
||||
|
||||
uint kernel_power_all = 0;
|
||||
|
||||
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];
|
||||
|
||||
hardware_power_all += device_param->hardware_power;
|
||||
|
||||
kernel_power_all += device_param->kernel_power;
|
||||
}
|
||||
|
||||
data.hardware_power_all = hardware_power_all; // hardware_power_all is the same as kernel_power_all but without the influence of kernel_accel on the devices
|
||||
|
||||
data.kernel_power_all = kernel_power_all;
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
if (data.words_base < kernel_power_all)
|
||||
{
|
||||
if (user_options->quiet == false)
|
||||
{
|
||||
clear_prompt ();
|
||||
|
||||
log_info ("ATTENTION!");
|
||||
log_info (" The wordlist or mask you are using is too small.");
|
||||
log_info (" Therefore, hashcat is unable to utilize the full parallelization power of your device(s).");
|
||||
log_info (" The cracking speed will drop.");
|
||||
log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
|
||||
log_info ("");
|
||||
}
|
||||
}
|
||||
}
|
||||
opencl_ctx_devices_update_power (opencl_ctx, user_options, user_options_extra);
|
||||
|
||||
/**
|
||||
* create cracker threads
|
||||
|
@ -753,7 +753,7 @@ int hm_get_throttle_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_
|
||||
clocksThrottleReasons &= ~nvmlClocksThrottleReasonApplicationsClocksSetting;
|
||||
clocksThrottleReasons &= ~nvmlClocksThrottleReasonUnknown;
|
||||
|
||||
if (data.kernel_power_final)
|
||||
if (opencl_ctx->kernel_power_final)
|
||||
{
|
||||
clocksThrottleReasons &= ~nvmlClocksThrottleReasonHwSlowdown;
|
||||
}
|
||||
|
46
src/opencl.c
46
src/opencl.c
@ -36,6 +36,7 @@
|
||||
#include "convert.h"
|
||||
#include "dictstat.h"
|
||||
#include "wordlist.h"
|
||||
#include "terminal.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
@ -2457,6 +2458,42 @@ void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx)
|
||||
opencl_ctx->need_xnvctrl = 0;
|
||||
}
|
||||
|
||||
void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
u32 kernel_power_all = 0;
|
||||
|
||||
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];
|
||||
|
||||
kernel_power_all += device_param->kernel_power;
|
||||
}
|
||||
|
||||
opencl_ctx->kernel_power_all = kernel_power_all;
|
||||
|
||||
/*
|
||||
* Inform user about possible slow speeds
|
||||
*/
|
||||
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
if (data.words_base < kernel_power_all)
|
||||
{
|
||||
if (user_options->quiet == false)
|
||||
{
|
||||
clear_prompt ();
|
||||
|
||||
log_info ("ATTENTION!");
|
||||
log_info (" The wordlist or mask you are using is too small.");
|
||||
log_info (" Therefore, hashcat is unable to utilize the full parallelization power of your device(s).");
|
||||
log_info (" The cracking speed will drop.");
|
||||
log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
|
||||
log_info ("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, const hashes_t *hashes, const straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db)
|
||||
{
|
||||
/**
|
||||
@ -2478,6 +2515,8 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, co
|
||||
opencl_ctx->force_jit_compilation = 1500;
|
||||
}
|
||||
|
||||
u32 hardware_power_all = 0;
|
||||
|
||||
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||
{
|
||||
cl_int CL_err = CL_SUCCESS;
|
||||
@ -2647,6 +2686,8 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, co
|
||||
|
||||
device_param->hardware_power = device_processors * kernel_threads;
|
||||
|
||||
hardware_power_all += device_param->hardware_power;
|
||||
|
||||
/**
|
||||
* create input buffers on device : calculate size of fixed memory buffers
|
||||
*/
|
||||
@ -4403,6 +4444,8 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, co
|
||||
}
|
||||
}
|
||||
|
||||
opencl_ctx->hardware_power_all = hardware_power_all;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -4562,6 +4605,9 @@ void opencl_session_reset (opencl_ctx_t *opencl_ctx)
|
||||
device_param->words_off = 0;
|
||||
device_param->words_done = 0;
|
||||
}
|
||||
|
||||
opencl_ctx->kernel_power_all = 0;
|
||||
opencl_ctx->kernel_power_final = 0;
|
||||
}
|
||||
|
||||
int opencl_session_update_combinator (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const combinator_ctx_t *combinator_ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user