1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-03-03 08:36:04 +00:00

Introduce opencl_ctx_t; not finished yet

This commit is contained in:
jsteube 2016-09-15 16:02:52 +02:00
parent d60e2529c1
commit 7ce2f2ff19
33 changed files with 2013 additions and 1865 deletions

View File

@ -8,7 +8,7 @@
#define OPENCL_VECTOR_WIDTH 0
int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig);
int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig);
void *thread_autotune (void *p);

View File

@ -26,11 +26,9 @@ typedef struct
* threads
*/
uint devices_status;
uint devices_cnt;
uint devices_active;
hc_device_param_t *devices_param;
opencl_ctx_t *opencl_ctx;
uint shutdown_inner;
uint shutdown_outer;
@ -74,12 +72,6 @@ typedef struct
int rule_len_l;
int rule_len_r;
/**
* opencl library stuff
*/
void *ocl;
/**
* hardware watchdog
*/
@ -181,7 +173,7 @@ typedef struct
char *truecrypt_keyfiles;
char *veracrypt_keyfiles;
uint veracrypt_pim;
uint workload_profile;
char *custom_charset_1;
char *custom_charset_2;
char *custom_charset_3;

View File

@ -15,8 +15,8 @@ int sort_by_hash_no_salt (const void *v1, const void *v2);
void save_hash ();
void check_hash (hc_device_param_t *device_param, plain_t *plain);
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, plain_t *plain);
int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashconfig_t *hashconfig);
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint salt_pos, hashconfig_t *hashconfig);
#endif // _HASH_MANAGEMENT_H

View File

@ -42,16 +42,16 @@ int hm_check_fanspeed_control (void *adl, hm_attrs_t *hm_device, u32 *valid_adl_
// int hm_get_device_num (void *adl, HM_ADAPTER_ADL hm_adapter_index, int *hm_device_num);
// void hm_get_opencl_busid_devid (hm_attrs_t *hm_device, uint opencl_num_devices, cl_device_id *devices);
int hm_get_threshold_slowdown_with_device_id (const uint device_id);
int hm_get_threshold_shutdown_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_fanpolicy_with_device_id (const uint device_id);
int hm_get_buslanes_with_device_id (const uint device_id);
int hm_get_utilization_with_device_id (const uint device_id);
int hm_get_memoryspeed_with_device_id (const uint device_id);
int hm_get_corespeed_with_device_id (const uint device_id);
int hm_get_throttle_with_device_id (const uint device_id);
int hm_get_threshold_slowdown_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_threshold_shutdown_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_temperature_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_fanspeed_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_fanpolicy_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_buslanes_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_utilization_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_memoryspeed_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_corespeed_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_get_throttle_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id);
int hm_set_fanspeed_with_device_id_adl (const uint device_id, const int fanspeed, const int fanpolicy);
int hm_set_fanspeed_with_device_id_nvapi (const uint device_id, const int fanspeed, const int fanpolicy);
int hm_set_fanspeed_with_device_id_xnvctrl (const uint device_id, const int fanspeed);

View File

@ -224,25 +224,71 @@ struct __hc_device_param
u32 kernel_params_memset_buf32[PARAMCNT];
};
uint setup_opencl_platforms_filter (char *opencl_platforms);
u32 setup_devices_filter (char *opencl_devices);
cl_device_type setup_device_types_filter (char *opencl_device_types);
typedef struct
{
int disable;
void *ocl;
cl_uint platforms_cnt;
cl_platform_id *platforms;
cl_uint platform_devices_cnt;
cl_device_id *platform_devices;
u32 devices_cnt;
u32 devices_active;
hc_device_param_t *devices_param;
u32 devices_status;
u32 opencl_platforms_filter;
u32 devices_filter;
cl_device_type device_types_filter;
u32 opencl_vector_width;
u32 opencl_vector_width_chgd;
u32 nvidia_spin_damp;
u32 nvidia_spin_damp_chgd;
uint kernel_loops;
uint kernel_loops_chgd;
uint kernel_accel;
uint kernel_accel_chgd;
uint workload_profile;
int need_adl;
int need_nvml;
int need_nvapi;
int need_xnvctrl;
} opencl_ctx_t;
void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources);
void writeProgramBin (char *dst, u8 *binary, size_t binary_size);
int gidd_to_pw_t (hc_device_param_t *device_param, const u64 gidd, pw_t *pw);
int gidd_to_pw_t (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw);
int choose_kernel (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration);
int run_kernel (const uint kern_run, hc_device_param_t *device_param, const uint num, const uint event_update, const uint iteration, hashconfig_t *hashconfig);
int run_kernel_mp (const uint kern_run, hc_device_param_t *device_param, const uint num);
int run_kernel_tm (hc_device_param_t *device_param);
int run_kernel_amp (hc_device_param_t *device_param, const uint num);
int run_kernel_memset (hc_device_param_t *device_param, cl_mem buf, const uint value, const uint num);
int run_kernel_bzero (hc_device_param_t *device_param, cl_mem buf, const size_t size);
int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration);
int run_kernel (const uint kern_run, opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint num, const uint event_update, const uint iteration, hashconfig_t *hashconfig);
int run_kernel_mp (const uint kern_run, opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint num);
int run_kernel_tm (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param);
int run_kernel_amp (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint num);
int run_kernel_memset (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cl_mem buf, const uint value, const uint num);
int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cl_mem buf, const size_t size);
int run_copy (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint pws_cnt);
int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint pws_cnt);
int run_cracker (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint pws_cnt);
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint pws_cnt);
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, const char *opencl_devices, const char *opencl_device_types, const uint opencl_vector_width, const uint opencl_vector_width_chgd, const uint nvidia_spin_damp, const uint nvidia_spin_damp_chgd, const uint workload_profile, const uint kernel_accel, const uint kernel_accel_chgd, const uint kernel_loops, const uint kernel_loops_chgd, const uint keyspace, const uint stdout_flag);
void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const uint quiet, const uint force, const uint benchmark, const uint machine_readable, const uint algorithm_pos);
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
#endif // _OPENCL_H

View File

@ -47,18 +47,18 @@ typedef struct
} restore_data_t;
u64 get_lowest_words_done ();
u64 get_lowest_words_done (opencl_ctx_t *opencl_ctx);
restore_data_t *init_restore (int argc, char **argv);
void read_restore (const char *eff_restore_file, restore_data_t *rd);
void write_restore (const char *new_restore_file, restore_data_t *rd);
void write_restore (opencl_ctx_t *opencl_ctx, const char *new_restore_file, restore_data_t *rd);
void cycle_restore ();
void cycle_restore (opencl_ctx_t *opencl_ctx);
void check_checkpoint ();
void check_checkpoint (opencl_ctx_t *opencl_ctx);
void stop_at_checkpoint ();
void stop_at_checkpoint (opencl_ctx_t *opencl_ctx);
#endif // _RESTORE_H

View File

@ -31,9 +31,9 @@ typedef enum status_rc
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
void status_display_machine_readable ();
void status_display ();
void status_benchmark_automate ();
void status_benchmark ();
void status_display_machine_readable (opencl_ctx_t *opencl_ctx);
void status_display (opencl_ctx_t *opencl_ctx);
void status_benchmark_automate (opencl_ctx_t *opencl_ctx);
void status_benchmark (opencl_ctx_t *opencl_ctx);
#endif // _STATUS_H

View File

@ -31,6 +31,6 @@ typedef struct
} out_t;
void process_stdout (hc_device_param_t *device_param, const uint pws_cnt);
void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint pws_cnt);
#endif // _STDOUT_H

View File

@ -62,12 +62,12 @@ void hc_signal (void (callback) (int));
#endif
void myabort ();
void myquit ();
void myabort (opencl_ctx_t *opencl_ctx);
void myquit (opencl_ctx_t *opencl_ctx);
void SuspendThreads ();
void ResumeThreads ();
void SuspendThreads (opencl_ctx_t *opencl_ctx);
void ResumeThreads (opencl_ctx_t *opencl_ctx);
void bypass ();
void bypass (opencl_ctx_t *opencl_ctx);
#endif // _THREAD_H

View File

@ -43,6 +43,6 @@ typedef struct
void tuning_db_destroy (tuning_db_t *tuning_db);
tuning_db_t *tuning_db_alloc (FILE *fp);
tuning_db_t *tuning_db_init (const char *tuning_db_file);
tuning_db_entry_t *tuning_db_search (tuning_db_t *tuning_db, hc_device_param_t *device_param, int attack_mode, int hash_type);
tuning_db_entry_t *tuning_db_search (const tuning_db_t *tuning_db, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type);
#endif // _TUNINGDB_H

View File

@ -8,6 +8,6 @@
#define WEAK_HASH_THRESHOLD 100
void weak_hash_check (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint salt_pos);
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint salt_pos);
#endif // _WEAK_HASH_H

View File

@ -14,11 +14,12 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -32,7 +33,7 @@ extern hc_global_data_t data;
static double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 };
static double try_run (hc_device_param_t *device_param, hashconfig_t *hashconfig, const u32 kernel_accel, const u32 kernel_loops)
static double try_run (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const u32 kernel_accel, const u32 kernel_loops)
{
const u32 kernel_power_try = device_param->device_processors * device_param->kernel_threads * kernel_accel;
@ -42,11 +43,11 @@ static double try_run (hc_device_param_t *device_param, hashconfig_t *hashconfig
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
run_kernel (KERN_RUN_1, device_param, kernel_power_try, true, 0, hashconfig);
run_kernel (KERN_RUN_1, opencl_ctx, device_param, kernel_power_try, true, 0, hashconfig);
}
else
{
run_kernel (KERN_RUN_2, device_param, kernel_power_try, true, 0, hashconfig);
run_kernel (KERN_RUN_2, opencl_ctx, device_param, kernel_power_try, true, 0, hashconfig);
}
const double exec_ms_prev = get_avg_exec_time (device_param, 1);
@ -54,9 +55,9 @@ static double try_run (hc_device_param_t *device_param, hashconfig_t *hashconfig
return exec_ms_prev;
}
int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig)
{
const double target_ms = TARGET_MS_PROFILE[data.workload_profile - 1];
const double target_ms = TARGET_MS_PROFILE[opencl_ctx->workload_profile - 1];
const u32 kernel_accel_min = device_param->kernel_accel_min;
const u32 kernel_accel_max = device_param->kernel_accel_max;
@ -75,10 +76,10 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
{
if (hashconfig->hash_mode != 2000)
{
try_run (device_param, hashconfig, kernel_accel, kernel_loops);
try_run (device_param, hashconfig, kernel_accel, kernel_loops);
try_run (device_param, hashconfig, kernel_accel, kernel_loops);
try_run (device_param, hashconfig, kernel_accel, kernel_loops);
try_run (opencl_ctx, device_param, hashconfig, kernel_accel, kernel_loops);
try_run (opencl_ctx, device_param, hashconfig, kernel_accel, kernel_loops);
try_run (opencl_ctx, device_param, hashconfig, kernel_accel, kernel_loops);
try_run (opencl_ctx, device_param, hashconfig, kernel_accel, kernel_loops);
}
device_param->kernel_accel = kernel_accel;
@ -98,7 +99,7 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
if (data.attack_kern == ATTACK_KERN_BF)
{
run_kernel_memset (device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t));
run_kernel_memset (opencl_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t));
}
else
{
@ -109,7 +110,7 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
device_param->pws_buf[i].pw_len = 7 + (i & 7);
}
cl_int CL_err = hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
cl_int CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
@ -123,7 +124,7 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
{
if (data.kernel_rules_cnt > 1)
{
cl_int CL_err = hc_clEnqueueCopyBuffer (data.ocl, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL);
cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
@ -135,7 +136,7 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
}
else
{
run_kernel_amp (device_param, kernel_power_max);
run_kernel_amp (opencl_ctx, device_param, kernel_power_max);
}
#define VERIFIER_CNT 1
@ -146,11 +147,11 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
{
for (kernel_loops = kernel_loops_max; kernel_loops > kernel_loops_min; kernel_loops >>= 1)
{
double exec_ms = try_run (device_param, hashconfig, kernel_accel_min, kernel_loops);
double exec_ms = try_run (opencl_ctx, device_param, hashconfig, kernel_accel_min, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_v = try_run (device_param, hashconfig, kernel_accel_min, kernel_loops);
double exec_ms_v = try_run (opencl_ctx, device_param, hashconfig, kernel_accel_min, kernel_loops);
exec_ms = MIN (exec_ms, exec_ms_v);
}
@ -172,11 +173,11 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
if (kernel_accel_try < kernel_accel_min) continue;
if (kernel_accel_try > kernel_accel_max) break;
double exec_ms = try_run (device_param, hashconfig, kernel_accel_try, kernel_loops);
double exec_ms = try_run (opencl_ctx, device_param, hashconfig, kernel_accel_try, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_v = try_run (device_param, hashconfig, kernel_accel_try, kernel_loops);
double exec_ms_v = try_run (opencl_ctx, device_param, hashconfig, kernel_accel_try, kernel_loops);
exec_ms = MIN (exec_ms, exec_ms_v);
}
@ -195,11 +196,11 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
// due to the rebalance it's possible that the runtime reduces from 48ms to 47ms
// and this creates the possibility to double the workload -> 47 * 2 = 95ms, which is < 96ms
double exec_ms_pre_final = try_run (device_param, hashconfig, kernel_accel, kernel_loops);
double exec_ms_pre_final = try_run (opencl_ctx, device_param, hashconfig, kernel_accel, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_pre_final_v = try_run (device_param, hashconfig, kernel_accel, kernel_loops);
double exec_ms_pre_final_v = try_run (opencl_ctx, device_param, hashconfig, kernel_accel, kernel_loops);
exec_ms_pre_final = MIN (exec_ms_pre_final, exec_ms_pre_final_v);
}
@ -225,11 +226,11 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
diff_new = diff;
double exec_ms = try_run (device_param, hashconfig, kernel_accel_try, kernel_loops_try);
double exec_ms = try_run (opencl_ctx, device_param, hashconfig, kernel_accel_try, kernel_loops_try);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_v = try_run (device_param, hashconfig, kernel_accel_try, kernel_loops_try);
double exec_ms_v = try_run (opencl_ctx, device_param, hashconfig, kernel_accel_try, kernel_loops_try);
exec_ms = MIN (exec_ms, exec_ms_v);
}
@ -262,15 +263,15 @@ int autotune (hc_device_param_t *device_param, hashconfig_t *hashconfig)
/*
memset (device_param->pws_buf, 0, kernel_power_max * sizeof (pw_t));
hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
*/
run_kernel_memset (device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t));
run_kernel_memset (opencl_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t));
if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL)
{
run_kernel_memset (device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t));
run_kernel_memset (opencl_ctx, device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t));
}
// reset timer
@ -317,9 +318,11 @@ void *thread_autotune (void *p)
if (device_param->skipped) return NULL;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
hashconfig_t *hashconfig = data.hashconfig;
autotune (device_param, hashconfig);
autotune (opencl_ctx, device_param, hashconfig);
return NULL;
}

View File

@ -13,11 +13,12 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"

View File

@ -16,13 +16,14 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "rp_cpu.h"
#include "terminal.h"
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -118,13 +119,15 @@ void *thread_calc_stdin (void *p)
if (device_param->skipped) return NULL;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
hashconfig_t *hashconfig = data.hashconfig;
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
const uint attack_kern = data.attack_kern;
while ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
while ((opencl_ctx->devices_status != STATUS_CRACKED) && (opencl_ctx->devices_status != STATUS_ABORTED) && (opencl_ctx->devices_status != STATUS_QUIT))
{
hc_thread_mutex_lock (mux_dispatcher);
@ -194,18 +197,18 @@ void *thread_calc_stdin (void *p)
words_cur++;
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_ABORTED) break;
if (opencl_ctx->devices_status == STATUS_QUIT) break;
if (opencl_ctx->devices_status == STATUS_BYPASS) break;
}
hc_thread_mutex_unlock (mux_dispatcher);
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_ABORTED) break;
if (opencl_ctx->devices_status == STATUS_QUIT) break;
if (opencl_ctx->devices_status == STATUS_BYPASS) break;
// flush
@ -213,9 +216,9 @@ void *thread_calc_stdin (void *p)
if (pws_cnt)
{
run_copy (device_param, hashconfig, pws_cnt);
run_copy (opencl_ctx, device_param, hashconfig, pws_cnt);
run_cracker (device_param, hashconfig, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, pws_cnt);
device_param->pws_cnt = 0;
@ -223,11 +226,11 @@ void *thread_calc_stdin (void *p)
still required?
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c);
run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c);
}
else if (attack_kern == ATTACK_KERN_COMBI)
{
run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs);
run_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, device_param->size_combs);
}
*/
}
@ -247,6 +250,8 @@ void *thread_calc (void *p)
if (device_param->skipped) return NULL;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
hashconfig_t *hashconfig = data.hashconfig;
const uint attack_mode = data.attack_mode;
@ -254,7 +259,7 @@ void *thread_calc (void *p)
if (attack_mode == ATTACK_MODE_BF)
{
while ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
while ((opencl_ctx->devices_status != STATUS_CRACKED) && (opencl_ctx->devices_status != STATUS_ABORTED) && (opencl_ctx->devices_status != STATUS_QUIT))
{
const uint work = get_work (device_param, -1u);
@ -269,9 +274,9 @@ void *thread_calc (void *p)
if (pws_cnt)
{
run_copy (device_param, hashconfig, pws_cnt);
run_copy (opencl_ctx, device_param, hashconfig, pws_cnt);
run_cracker (device_param, hashconfig, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, pws_cnt);
device_param->pws_cnt = 0;
@ -281,12 +286,12 @@ void *thread_calc (void *p)
*/
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (opencl_ctx->devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint (opencl_ctx);
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_ABORTED) break;
if (opencl_ctx->devices_status == STATUS_QUIT) break;
if (opencl_ctx->devices_status == STATUS_BYPASS) break;
if (data.benchmark == 1) break;
@ -366,7 +371,7 @@ void *thread_calc (void *p)
u64 words_cur = 0;
while ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
while ((opencl_ctx->devices_status != STATUS_CRACKED) && (opencl_ctx->devices_status != STATUS_ABORTED) && (opencl_ctx->devices_status != STATUS_QUIT))
{
u64 words_off = 0;
u64 words_fin = 0;
@ -456,28 +461,28 @@ void *thread_calc (void *p)
pw_add (device_param, (u8 *) line_buf, line_len);
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (opencl_ctx->devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint (opencl_ctx);
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_ABORTED) break;
if (opencl_ctx->devices_status == STATUS_QUIT) break;
if (opencl_ctx->devices_status == STATUS_BYPASS) break;
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (opencl_ctx->devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint (opencl_ctx);
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_ABORTED) break;
if (opencl_ctx->devices_status == STATUS_QUIT) break;
if (opencl_ctx->devices_status == STATUS_BYPASS) break;
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (opencl_ctx->devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint (opencl_ctx);
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_ABORTED) break;
if (opencl_ctx->devices_status == STATUS_QUIT) break;
if (opencl_ctx->devices_status == STATUS_BYPASS) break;
//
// flush
@ -487,9 +492,9 @@ void *thread_calc (void *p)
if (pws_cnt)
{
run_copy (device_param, hashconfig, pws_cnt);
run_copy (opencl_ctx, device_param, hashconfig, pws_cnt);
run_cracker (device_param, hashconfig, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, pws_cnt);
device_param->pws_cnt = 0;
@ -506,12 +511,12 @@ void *thread_calc (void *p)
*/
}
if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
if (opencl_ctx->devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint (opencl_ctx);
if (data.devices_status == STATUS_CRACKED) break;
if (data.devices_status == STATUS_ABORTED) break;
if (data.devices_status == STATUS_QUIT) break;
if (data.devices_status == STATUS_BYPASS) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_ABORTED) break;
if (opencl_ctx->devices_status == STATUS_QUIT) break;
if (opencl_ctx->devices_status == STATUS_BYPASS) break;
if (words_fin == 0) break;

View File

@ -141,9 +141,9 @@ void ocl_close (OCL_PTR *ocl)
if (ocl)
{
if (ocl->lib)
{
hc_dlclose (ocl->lib);
myfree (ocl);
}
}
}

View File

@ -15,11 +15,13 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -27,7 +29,6 @@
#include "data.h"
#include "terminal.h"
#include "status.h"
#include "thread.h"
#include "rp_kernel_on_cpu.h"
#include "hash_management.h"
@ -222,7 +223,7 @@ void save_hash ()
unlink (old_hashfile);
}
void check_hash (hc_device_param_t *device_param, plain_t *plain)
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, plain_t *plain)
{
debugfile_ctx_t *debugfile_ctx = data.debugfile_ctx;
loopback_ctx_t *loopback_ctx = data.loopback_ctx;
@ -271,7 +272,7 @@ void check_hash (hc_device_param_t *device_param, plain_t *plain)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
@ -319,7 +320,7 @@ void check_hash (hc_device_param_t *device_param, plain_t *plain)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
@ -377,7 +378,7 @@ void check_hash (hc_device_param_t *device_param, plain_t *plain)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
@ -408,7 +409,7 @@ void check_hash (hc_device_param_t *device_param, plain_t *plain)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
@ -481,7 +482,7 @@ void check_hash (hc_device_param_t *device_param, plain_t *plain)
if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
{
if ((data.devices_status != STATUS_CRACKED) && (data.status != 1))
if ((opencl_ctx->devices_status != STATUS_CRACKED) && (data.status != 1))
{
if (outfile_ctx->filename == NULL) if (quiet == 0) send_prompt ();
}
@ -510,7 +511,7 @@ void check_hash (hc_device_param_t *device_param, plain_t *plain)
}
}
int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashconfig_t *hashconfig)
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint salt_pos, hashconfig_t *hashconfig)
{
salt_t *salt_buf = &data.salts_buf[salt_pos];
@ -518,7 +519,7 @@ int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashcon
cl_int CL_err;
CL_err = hc_clEnqueueReadBuffer (data.ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL);
CL_err = hc_clEnqueueReadBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
@ -535,7 +536,7 @@ int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashcon
plain_t *cracked = (plain_t *) mycalloc (num_cracked, sizeof (plain_t));
CL_err = hc_clEnqueueReadBuffer (data.ocl, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL);
CL_err = hc_clEnqueueReadBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
@ -572,9 +573,9 @@ int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashcon
}
}
if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
if (data.salts_done == data.salts_cnt) opencl_ctx->devices_status = STATUS_CRACKED;
check_hash (device_param, &cracked[i]);
check_hash (opencl_ctx, device_param, &cracked[i]);
}
hc_thread_mutex_unlock (mux_display);
@ -605,7 +606,7 @@ int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashcon
memset (data.digests_shown_tmp, 0, salt_buf->digests_cnt * sizeof (uint));
CL_err = hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (uint), salt_buf->digests_cnt * sizeof (uint), &data.digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL);
CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (uint), salt_buf->digests_cnt * sizeof (uint), &data.digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
@ -617,7 +618,7 @@ int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashcon
num_cracked = 0;
CL_err = hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL);
CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
@ -629,5 +630,3 @@ int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashcon
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -19,15 +19,16 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "filehandling.h"
#include "rp_cpu.h"
#include "inc_hash_constants.h"
#include "shared.h"
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"

View File

@ -15,11 +15,12 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "outfile.h"
#include "potfile.h"
@ -413,11 +414,11 @@ int hm_get_adapter_index_adl (hm_attrs_t *hm_device, u32 *valid_adl_device_list,
return num_adl_adapters;
}
int hm_get_threshold_slowdown_with_device_id (const uint device_id)
int hm_get_threshold_slowdown_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -439,7 +440,7 @@ int hm_get_threshold_slowdown_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
int target = 0;
@ -451,11 +452,11 @@ int hm_get_threshold_slowdown_with_device_id (const uint device_id)
return -1;
}
int hm_get_threshold_shutdown_with_device_id (const uint device_id)
int hm_get_threshold_shutdown_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -470,7 +471,7 @@ int hm_get_threshold_shutdown_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
int target = 0;
@ -482,11 +483,11 @@ int hm_get_threshold_shutdown_with_device_id (const uint device_id)
return -1;
}
int hm_get_temperature_with_device_id (const uint device_id)
int hm_get_temperature_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -511,7 +512,7 @@ int hm_get_temperature_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
int temperature = 0;
@ -523,13 +524,13 @@ int hm_get_temperature_with_device_id (const uint device_id)
return -1;
}
int hm_get_fanpolicy_with_device_id (const uint device_id)
int hm_get_fanpolicy_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.hm_device[device_id].fan_get_supported == 1)
{
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -553,7 +554,7 @@ int hm_get_fanpolicy_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
return 1;
}
@ -562,13 +563,13 @@ int hm_get_fanpolicy_with_device_id (const uint device_id)
return -1;
}
int hm_get_fanspeed_with_device_id (const uint device_id)
int hm_get_fanspeed_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.hm_device[device_id].fan_get_supported == 1)
{
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -599,7 +600,7 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
int speed = 0;
@ -612,11 +613,11 @@ int hm_get_fanspeed_with_device_id (const uint device_id)
return -1;
}
int hm_get_buslanes_with_device_id (const uint device_id)
int hm_get_buslanes_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -630,7 +631,7 @@ int hm_get_buslanes_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
unsigned int currLinkWidth;
@ -642,11 +643,11 @@ int hm_get_buslanes_with_device_id (const uint device_id)
return -1;
}
int hm_get_utilization_with_device_id (const uint device_id)
int hm_get_utilization_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -660,7 +661,7 @@ int hm_get_utilization_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
nvmlUtilization_t utilization;
@ -672,11 +673,11 @@ int hm_get_utilization_with_device_id (const uint device_id)
return -1;
}
int hm_get_memoryspeed_with_device_id (const uint device_id)
int hm_get_memoryspeed_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -690,7 +691,7 @@ int hm_get_memoryspeed_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
unsigned int clock;
@ -702,11 +703,11 @@ int hm_get_memoryspeed_with_device_id (const uint device_id)
return -1;
}
int hm_get_corespeed_with_device_id (const uint device_id)
int hm_get_corespeed_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
if (data.hm_adl)
{
@ -720,7 +721,7 @@ int hm_get_corespeed_with_device_id (const uint device_id)
}
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
unsigned int clock;
@ -732,16 +733,16 @@ int hm_get_corespeed_with_device_id (const uint device_id)
return -1;
}
int hm_get_throttle_with_device_id (const uint device_id)
int hm_get_throttle_with_device_id (opencl_ctx_t *opencl_ctx, const uint device_id)
{
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) return -1;
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_AMD)
{
}
if (data.devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
if (opencl_ctx->devices_param[device_id].device_vendor_id == VENDOR_ID_NV)
{
unsigned long long clocksThrottleReasons = 0;
unsigned long long supportedThrottleReasons = 0;

View File

@ -19,10 +19,11 @@
#include "ext_xnvctrl.h"
#include "types.h"
#include "memory.h"
#include "hwmon.h"
#include "rp_cpu.h"
#include "mpsp.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"

View File

@ -15,11 +15,13 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -28,8 +30,6 @@
#include "status.h"
#include "shared.h"
#include "terminal.h"
#include "hwmon.h"
#include "thread.h"
#include "monitor.h"
#include "hash_management.h"
@ -49,6 +49,8 @@ void *thread_monitor (void *p)
uint remove_left = data.remove_timer;
uint status_left = data.status_timer;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
#if defined (HAVE_HWMON)
uint hwmon_check = 0;
@ -56,12 +58,12 @@ void *thread_monitor (void *p)
// these variables are mainly used for fan control
int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
int *fan_speed_chgd = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int));
// temperature controller "loopback" values
int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int));
int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int));
int *temp_diff_old = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int));
int *temp_diff_sum = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int));
int temp_threshold = 1; // degrees celcius
@ -114,7 +116,7 @@ void *thread_monitor (void *p)
{
hc_sleep (sleep_time);
if (data.devices_status != STATUS_RUNNING) continue;
if (opencl_ctx->devices_status != STATUS_RUNNING) continue;
#if defined (HAVE_HWMON)
@ -122,9 +124,9 @@ void *thread_monitor (void *p)
{
hc_thread_mutex_lock (mux_hwmon);
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -188,21 +190,21 @@ void *thread_monitor (void *p)
if (Ta == 0) Ta = 1;
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
if ((data.devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
if ((opencl_ctx->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 temperature = hm_get_temperature_with_device_id (opencl_ctx, device_id);
if (temperature > (int) data.gpu_temp_abort)
{
log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", device_id + 1);
if (data.devices_status != STATUS_QUIT) myabort ();
if (opencl_ctx->devices_status != STATUS_QUIT) myabort (opencl_ctx);
break;
}
@ -233,7 +235,7 @@ void *thread_monitor (void *p)
if (abs (fan_diff_required) >= temp_threshold)
{
const int fan_speed_cur = hm_get_fanspeed_with_device_id (device_id);
const int fan_speed_cur = hm_get_fanspeed_with_device_id (opencl_ctx, device_id);
int fan_speed_level = fan_speed_cur;
@ -286,7 +288,7 @@ void *thread_monitor (void *p)
if (restore_left == 0)
{
if (data.restore_disable == 0) cycle_restore ();
if (data.restore_disable == 0) cycle_restore (opencl_ctx);
restore_left = data.restore_timer;
}
@ -296,7 +298,7 @@ void *thread_monitor (void *p)
{
double ms_paused = data.ms_paused;
if (data.devices_status == STATUS_PAUSED)
if (opencl_ctx->devices_status == STATUS_PAUSED)
{
double ms_paused_tmp = 0;
@ -318,7 +320,7 @@ void *thread_monitor (void *p)
if (data.quiet == 0) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
}
if (data.devices_status != STATUS_QUIT) myabort ();
if (opencl_ctx->devices_status != STATUS_QUIT) myabort (opencl_ctx);
}
}
@ -351,7 +353,7 @@ void *thread_monitor (void *p)
if (data.quiet == 0) log_info ("");
status_display ();
status_display (opencl_ctx);
if (data.quiet == 0) log_info ("");

View File

@ -21,18 +21,18 @@
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "filehandling.h"
#include "tuningdb.h"
#include "opencl.h"
#include "thread.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
//#include "shared.h"
extern hc_global_data_t data;

File diff suppressed because it is too large Load Diff

View File

@ -15,11 +15,12 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -37,6 +38,8 @@ void *thread_outfile_remove (void *p)
{
// some hash-dependent constants
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
hashconfig_t *hashconfig = data.hashconfig;
uint dgst_size = hashconfig->dgst_size;
@ -72,7 +75,7 @@ void *thread_outfile_remove (void *p)
{
hc_sleep (1);
if (data.devices_status != STATUS_RUNNING) continue;
if (opencl_ctx->devices_status != STATUS_RUNNING) continue;
check_left--;
@ -278,23 +281,23 @@ void *thread_outfile_remove (void *p)
data.salts_done++;
if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
if (data.salts_done == data.salts_cnt) opencl_ctx->devices_status = STATUS_CRACKED;
}
}
}
if (data.devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
}
}
if (found) break;
if (data.devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
iter--;
}
if (data.devices_status == STATUS_CRACKED) break;
if (opencl_ctx->devices_status == STATUS_CRACKED) break;
}
myfree (line_buf);

View File

@ -15,12 +15,13 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "rp_cpu.h"
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -39,13 +40,13 @@ static void fsync (int fd)
}
#endif
u64 get_lowest_words_done ()
u64 get_lowest_words_done (opencl_ctx_t *opencl_ctx)
{
u64 words_cur = -1llu;
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -238,9 +239,9 @@ void read_restore (const char *eff_restore_file, restore_data_t *rd)
}
}
void write_restore (const char *new_restore_file, restore_data_t *rd)
void write_restore (opencl_ctx_t *opencl_ctx, const char *new_restore_file, restore_data_t *rd)
{
u64 words_cur = get_lowest_words_done ();
u64 words_cur = get_lowest_words_done (opencl_ctx);
rd->words_cur = words_cur;
@ -275,14 +276,14 @@ void write_restore (const char *new_restore_file, restore_data_t *rd)
fclose (fp);
}
void cycle_restore ()
void cycle_restore (opencl_ctx_t *opencl_ctx)
{
const char *eff_restore_file = data.eff_restore_file;
const char *new_restore_file = data.new_restore_file;
restore_data_t *rd = data.rd;
write_restore (new_restore_file, rd);
write_restore (opencl_ctx, new_restore_file, rd);
struct stat st;
@ -302,23 +303,23 @@ void cycle_restore ()
}
}
void check_checkpoint ()
void check_checkpoint (opencl_ctx_t *opencl_ctx)
{
// if (data.restore_disable == 1) break; (this is already implied by previous checks)
u64 words_cur = get_lowest_words_done ();
u64 words_cur = get_lowest_words_done (opencl_ctx);
if (words_cur != data.checkpoint_cur_words)
{
myabort ();
myabort (opencl_ctx);
}
}
void stop_at_checkpoint ()
void stop_at_checkpoint (opencl_ctx_t *opencl_ctx)
{
if (data.devices_status != STATUS_STOP_AT_CHECKPOINT)
if (opencl_ctx->devices_status != STATUS_STOP_AT_CHECKPOINT)
{
if (data.devices_status != STATUS_RUNNING) return;
if (opencl_ctx->devices_status != STATUS_RUNNING) return;
}
// this feature only makes sense if --restore-disable was not specified
@ -332,19 +333,19 @@ void stop_at_checkpoint ()
// check if monitoring of Restore Point updates should be enabled or disabled
if (data.devices_status != STATUS_STOP_AT_CHECKPOINT)
if (opencl_ctx->devices_status != STATUS_STOP_AT_CHECKPOINT)
{
data.devices_status = STATUS_STOP_AT_CHECKPOINT;
opencl_ctx->devices_status = STATUS_STOP_AT_CHECKPOINT;
// save the current restore point value
data.checkpoint_cur_words = get_lowest_words_done ();
data.checkpoint_cur_words = get_lowest_words_done (opencl_ctx);
log_info ("Checkpoint enabled: Will quit at next Restore Point update");
}
else
{
data.devices_status = STATUS_RUNNING;
opencl_ctx->devices_status = STATUS_RUNNING;
// reset the global value for checkpoint checks

View File

@ -20,14 +20,15 @@
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "convert.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "rp_cpu.h"
#include "terminal.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"

View File

@ -15,19 +15,19 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "rp_cpu.h"
#include "terminal.h"
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
//#include "shared.h"
#include "status.h"
static const char ST_0000[] = "Initializing";
@ -170,11 +170,11 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en
return exec_ms_sum / exec_ms_cnt;
}
void status_display_machine_readable ()
void status_display_machine_readable (opencl_ctx_t *opencl_ctx)
{
FILE *out = stdout;
fprintf (out, "STATUS\t%u\t", data.devices_status);
fprintf (out, "STATUS\t%u\t", opencl_ctx->devices_status);
/**
* speed new
@ -182,9 +182,9 @@ void status_display_machine_readable ()
fprintf (out, "SPEED\t");
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -209,9 +209,9 @@ void status_display_machine_readable ()
fprintf (out, "EXEC_RUNTIME\t");
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -224,7 +224,7 @@ void status_display_machine_readable ()
* words_cur
*/
u64 words_cur = get_lowest_words_done ();
u64 words_cur = get_lowest_words_done (opencl_ctx);
fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur);
@ -291,13 +291,13 @@ void status_display_machine_readable ()
hc_thread_mutex_lock (mux_hwmon);
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
int temp = hm_get_temperature_with_device_id (device_id);
int temp = hm_get_temperature_with_device_id (opencl_ctx, device_id);
fprintf (out, "%d\t", temp);
}
@ -314,10 +314,10 @@ void status_display_machine_readable ()
fflush (out);
}
void status_display ()
void status_display (opencl_ctx_t *opencl_ctx)
{
if (data.devices_status == STATUS_INIT) return;
if (data.devices_status == STATUS_STARTING) return;
if (opencl_ctx->devices_status == STATUS_INIT) return;
if (opencl_ctx->devices_status == STATUS_STARTING) return;
hashconfig_t *hashconfig = data.hashconfig;
void *digests_buf = data.digests_buf;
@ -331,7 +331,7 @@ void status_display ()
if (data.machine_readable == 1)
{
status_display_machine_readable ();
status_display_machine_readable (opencl_ctx);
return;
}
@ -342,7 +342,7 @@ void status_display ()
log_info ("Session.Name...: %s", data.session);
char *status_type = strstatus (data.devices_status);
char *status_type = strstatus (opencl_ctx->devices_status);
uint hash_mode = hashconfig->hash_mode;
@ -609,9 +609,9 @@ void status_display ()
u64 speed_cnt[DEVICES_MAX] = { 0 };
double speed_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -632,9 +632,9 @@ void status_display ()
double hashes_dev_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -654,9 +654,9 @@ void status_display ()
double exec_all_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -675,7 +675,7 @@ void status_display ()
double ms_paused = data.ms_paused;
if (data.devices_status == STATUS_PAUSED)
if (opencl_ctx->devices_status == STATUS_PAUSED)
{
double ms_paused_tmp = 0;
@ -795,7 +795,7 @@ void status_display ()
if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
{
if (data.devices_status != STATUS_CRACKED)
if (opencl_ctx->devices_status != STATUS_CRACKED)
{
#if defined (_WIN)
__time64_t sec_etc = 0;
@ -899,9 +899,9 @@ void status_display ()
}
}
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -920,7 +920,7 @@ void status_display ()
format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
if (data.devices_active > 1) log_info ("Speed.Dev.#*...: %9sH/s", display_all_cur);
if (opencl_ctx->devices_active > 1) log_info ("Speed.Dev.#*...: %9sH/s", display_all_cur);
const double digests_percent = (double) data.digests_done / data.digests_cnt;
const double salts_percent = (double) data.salts_done / data.salts_cnt;
@ -1002,7 +1002,7 @@ void status_display ()
// Restore point
u64 restore_point = get_lowest_words_done ();
u64 restore_point = get_lowest_words_done (opencl_ctx);
u64 restore_total = data.words_base;
@ -1062,28 +1062,28 @@ void status_display ()
#if defined (HAVE_HWMON)
if (data.devices_status == STATUS_EXHAUSTED) return;
if (data.devices_status == STATUS_CRACKED) return;
if (data.devices_status == STATUS_ABORTED) return;
if (data.devices_status == STATUS_QUIT) return;
if (opencl_ctx->devices_status == STATUS_EXHAUSTED) return;
if (opencl_ctx->devices_status == STATUS_CRACKED) return;
if (opencl_ctx->devices_status == STATUS_ABORTED) return;
if (opencl_ctx->devices_status == STATUS_QUIT) return;
if (data.gpu_temp_disable == 0)
{
hc_thread_mutex_lock (mux_hwmon);
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
const int num_temperature = hm_get_temperature_with_device_id (device_id);
const int num_fanspeed = hm_get_fanspeed_with_device_id (device_id);
const int num_utilization = hm_get_utilization_with_device_id (device_id);
const int num_corespeed = hm_get_corespeed_with_device_id (device_id);
const int num_memoryspeed = hm_get_memoryspeed_with_device_id (device_id);
const int num_buslanes = hm_get_buslanes_with_device_id (device_id);
const int num_throttle = hm_get_throttle_with_device_id (device_id);
const int num_temperature = hm_get_temperature_with_device_id (opencl_ctx, device_id);
const int num_fanspeed = hm_get_fanspeed_with_device_id (opencl_ctx, device_id);
const int num_utilization = hm_get_utilization_with_device_id (opencl_ctx, device_id);
const int num_corespeed = hm_get_corespeed_with_device_id (opencl_ctx, device_id);
const int num_memoryspeed = hm_get_memoryspeed_with_device_id (opencl_ctx, device_id);
const int num_buslanes = hm_get_buslanes_with_device_id (opencl_ctx, device_id);
const int num_throttle = hm_get_throttle_with_device_id (opencl_ctx, device_id);
char output_buf[256] = { 0 };
@ -1154,16 +1154,16 @@ void status_display ()
#endif // HAVE_HWMON
}
void status_benchmark_automate ()
void status_benchmark_automate (opencl_ctx_t *opencl_ctx)
{
hashconfig_t *hashconfig = data.hashconfig;
u64 speed_cnt[DEVICES_MAX] = { 0 };
double speed_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -1173,9 +1173,9 @@ void status_benchmark_automate ()
double hashes_dev_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -1187,9 +1187,9 @@ void status_benchmark_automate ()
}
}
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -1197,16 +1197,16 @@ void status_benchmark_automate ()
}
}
void status_benchmark ()
void status_benchmark (opencl_ctx_t *opencl_ctx)
{
if (data.devices_status == STATUS_INIT) return;
if (data.devices_status == STATUS_STARTING) return;
if (opencl_ctx->devices_status == STATUS_INIT) return;
if (opencl_ctx->devices_status == STATUS_STARTING) return;
if (data.shutdown_inner == 1) return;
if (data.machine_readable == 1)
{
status_benchmark_automate ();
status_benchmark_automate (opencl_ctx);
return;
}
@ -1214,9 +1214,9 @@ void status_benchmark ()
u64 speed_cnt[DEVICES_MAX] = { 0 };
double speed_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -1228,9 +1228,9 @@ void status_benchmark ()
double hashes_dev_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -1250,9 +1250,9 @@ void status_benchmark ()
double exec_all_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -1261,9 +1261,9 @@ void status_benchmark ()
exec_all_ms[device_id] = exec_ms_avg;
}
for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &data.devices_param[device_id];
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
@ -1273,7 +1273,7 @@ void status_benchmark ()
format_speed_display (hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur));
if (data.devices_active >= 10)
if (opencl_ctx->devices_active >= 10)
{
log_info ("Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]);
}
@ -1289,5 +1289,5 @@ void status_benchmark ()
format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
if (data.devices_active > 1) log_info ("Speed.Dev.#*.: %9sH/s", display_all_cur);
if (opencl_ctx->devices_active > 1) log_info ("Speed.Dev.#*.: %9sH/s", display_all_cur);
}

View File

@ -17,15 +17,16 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "locking.h"
#include "rp_cpu.h"
#include "rp_kernel_on_cpu.h"
#include "shared.h"
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -58,7 +59,7 @@ static void out_push (out_t *out, const u8 *pw_buf, const int pw_len)
}
}
void process_stdout (hc_device_param_t *device_param, const uint pws_cnt)
void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint pws_cnt)
{
out_t out;
@ -98,7 +99,7 @@ void process_stdout (hc_device_param_t *device_param, const uint pws_cnt)
for (uint gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
const uint pos = device_param->innerloop_pos;
@ -125,7 +126,7 @@ void process_stdout (hc_device_param_t *device_param, const uint pws_cnt)
for (uint gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
for (uint il_pos = 0; il_pos < il_cnt; il_pos++)
{
@ -191,7 +192,7 @@ void process_stdout (hc_device_param_t *device_param, const uint pws_cnt)
for (uint gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
for (uint il_pos = 0; il_pos < il_cnt; il_pos++)
{
@ -221,7 +222,7 @@ void process_stdout (hc_device_param_t *device_param, const uint pws_cnt)
for (uint gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (device_param, gidvid, &pw);
gidd_to_pw_t (opencl_ctx, device_param, gidvid, &pw);
for (uint il_pos = 0; il_pos < il_cnt; il_pos++)
{

View File

@ -14,17 +14,18 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
#include "thread.h"
#include "status.h"
#include "terminal.h"
@ -57,6 +58,8 @@ void clear_prompt ()
void *thread_keypress (void *p)
{
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
uint quiet = data.quiet;
tty_break();
@ -86,7 +89,7 @@ void *thread_keypress (void *p)
log_info ("");
status_display ();
status_display (opencl_ctx);
log_info ("");
@ -98,7 +101,7 @@ void *thread_keypress (void *p)
log_info ("");
bypass ();
bypass (opencl_ctx);
log_info ("");
@ -110,7 +113,7 @@ void *thread_keypress (void *p)
log_info ("");
SuspendThreads ();
SuspendThreads (opencl_ctx);
log_info ("");
@ -122,7 +125,7 @@ void *thread_keypress (void *p)
log_info ("");
ResumeThreads ();
ResumeThreads (opencl_ctx);
log_info ("");
@ -134,7 +137,7 @@ void *thread_keypress (void *p)
log_info ("");
stop_at_checkpoint ();
stop_at_checkpoint (opencl_ctx);
log_info ("");
@ -146,7 +149,7 @@ void *thread_keypress (void *p)
log_info ("");
myabort ();
myabort (opencl_ctx);
break;
}

View File

@ -16,13 +16,14 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "rp_cpu.h"
#include "terminal.h"
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -50,7 +51,7 @@ BOOL WINAPI sigHandler_default (DWORD sig)
* function otherwise it is too late (e.g. after returning from this function)
*/
myabort ();
myabort (data.opencl_ctx);
SetConsoleCtrlHandler (NULL, TRUE);
@ -62,7 +63,7 @@ BOOL WINAPI sigHandler_default (DWORD sig)
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
myabort ();
myabort (data.opencl_ctx);
SetConsoleCtrlHandler (NULL, TRUE);
@ -78,7 +79,7 @@ BOOL WINAPI sigHandler_benchmark (DWORD sig)
{
case CTRL_CLOSE_EVENT:
myquit ();
myquit (data.opencl_ctx);
SetConsoleCtrlHandler (NULL, TRUE);
@ -90,7 +91,7 @@ BOOL WINAPI sigHandler_benchmark (DWORD sig)
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
myquit ();
myquit (data.opencl_ctx);
SetConsoleCtrlHandler (NULL, TRUE);
@ -116,14 +117,14 @@ void hc_signal (BOOL WINAPI (callback) (DWORD))
void sigHandler_default (int sig)
{
myabort ();
myabort (data.opencl_ctx);
signal (sig, NULL);
}
void sigHandler_benchmark (int sig)
{
myquit ();
myquit (data.opencl_ctx);
signal (sig, NULL);
}
@ -139,30 +140,30 @@ void hc_signal (void (callback) (int))
#endif
void myabort ()
void myabort (opencl_ctx_t *opencl_ctx)
{
data.devices_status = STATUS_ABORTED;
opencl_ctx->devices_status = STATUS_ABORTED;
}
void myquit ()
void myquit (opencl_ctx_t *opencl_ctx)
{
data.devices_status = STATUS_QUIT;
opencl_ctx->devices_status = STATUS_QUIT;
}
void SuspendThreads ()
void SuspendThreads (opencl_ctx_t *opencl_ctx)
{
if (data.devices_status != STATUS_RUNNING) return;
if (opencl_ctx->devices_status != STATUS_RUNNING) return;
hc_timer_set (&data.timer_paused);
data.devices_status = STATUS_PAUSED;
opencl_ctx->devices_status = STATUS_PAUSED;
log_info ("Paused");
}
void ResumeThreads ()
void ResumeThreads (opencl_ctx_t *opencl_ctx)
{
if (data.devices_status != STATUS_PAUSED) return;
if (opencl_ctx->devices_status != STATUS_PAUSED) return;
double ms_paused;
@ -170,14 +171,14 @@ void ResumeThreads ()
data.ms_paused += ms_paused;
data.devices_status = STATUS_RUNNING;
opencl_ctx->devices_status = STATUS_RUNNING;
log_info ("Resumed");
}
void bypass ()
void bypass (opencl_ctx_t *opencl_ctx)
{
data.devices_status = STATUS_BYPASS;
opencl_ctx->devices_status = STATUS_BYPASS;
log_info ("Next dictionary / mask in queue selected, bypassing current one");
}

View File

@ -12,8 +12,8 @@
#include "memory.h"
#include "filehandling.h"
#include "ext_OpenCL.h"
#include "opencl.h"
#include "tuningdb.h"
#include "opencl.h"
static int sort_by_tuning_db_alias (const void *v1, const void *v2)
{
@ -255,13 +255,13 @@ tuning_db_t *tuning_db_init (const char *tuning_db_file)
return tuning_db;
}
tuning_db_entry_t *tuning_db_search (tuning_db_t *tuning_db, hc_device_param_t *device_param, int attack_mode, int hash_type)
tuning_db_entry_t *tuning_db_search (const tuning_db_t *tuning_db, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type)
{
static tuning_db_entry_t s;
// first we need to convert all spaces in the device_name to underscore
char *device_name_nospace = mystrdup (device_param->device_name);
char *device_name_nospace = mystrdup (device_name);
int device_name_length = strlen (device_name_nospace);
@ -324,15 +324,15 @@ tuning_db_entry_t *tuning_db_search (tuning_db_t *tuning_db, hc_device_param_t *
// or by device type
if (device_param->device_type & CL_DEVICE_TYPE_CPU)
if (device_type & CL_DEVICE_TYPE_CPU)
{
s.device_name = "DEVICE_TYPE_CPU";
}
else if (device_param->device_type & CL_DEVICE_TYPE_GPU)
else if (device_type & CL_DEVICE_TYPE_GPU)
{
s.device_name = "DEVICE_TYPE_GPU";
}
else if (device_param->device_type & CL_DEVICE_TYPE_ACCELERATOR)
else if (device_type & CL_DEVICE_TYPE_ACCELERATOR)
{
s.device_name = "DEVICE_TYPE_ACCELERATOR";
}

View File

@ -14,11 +14,12 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -29,7 +30,7 @@
extern hc_global_data_t data;
void weak_hash_check (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint salt_pos)
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint salt_pos)
{
if (device_param == NULL)
{
@ -63,11 +64,11 @@ void weak_hash_check (hc_device_param_t *device_param, hashconfig_t *hashconfig,
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
run_kernel (KERN_RUN_1, device_param, 1, false, 0, hashconfig);
run_kernel (KERN_RUN_1, opencl_ctx, device_param, 1, false, 0, hashconfig);
}
else
{
run_kernel (KERN_RUN_1, device_param, 1, false, 0, hashconfig);
run_kernel (KERN_RUN_1, opencl_ctx, device_param, 1, false, 0, hashconfig);
uint loop_step = 16;
@ -82,17 +83,17 @@ void weak_hash_check (hc_device_param_t *device_param, hashconfig_t *hashconfig,
device_param->kernel_params_buf32[28] = loop_pos;
device_param->kernel_params_buf32[29] = loop_left;
run_kernel (KERN_RUN_2, device_param, 1, false, 0, hashconfig);
run_kernel (KERN_RUN_2, opencl_ctx, device_param, 1, false, 0, hashconfig);
}
run_kernel (KERN_RUN_3, device_param, 1, false, 0, hashconfig);
run_kernel (KERN_RUN_3, opencl_ctx, device_param, 1, false, 0, hashconfig);
}
/**
* result
*/
check_cracked (device_param, salt_pos, hashconfig);
check_cracked (opencl_ctx, device_param, salt_pos, hashconfig);
/**
* cleanup

View File

@ -17,17 +17,17 @@
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "thread.h"
#include "locking.h"
#include "rp_cpu.h"
#include "rp_kernel_on_cpu.h"
#include "shared.h"
#include "hwmon.h"
#include "thread.h"
#include "dictstat.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"