From ced3b3b82f0bded69b31ce617490ac87ff981180 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 20 Sep 2016 13:26:19 +0200 Subject: [PATCH] Move global mux_counter variable into opencl_ctx_t --- include/types.h | 1 + src/dispatch.c | 14 ++++++-------- src/hashcat.c | 3 --- src/opencl.c | 7 ++++--- src/status.c | 1 - 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/types.h b/include/types.h index c41ca2a2f..45f2280d9 100644 --- a/include/types.h +++ b/include/types.h @@ -535,6 +535,7 @@ typedef struct int force_jit_compilation; hc_thread_mutex_t mux_dispatcher; + hc_thread_mutex_t mux_counter; } opencl_ctx_t; diff --git a/src/dispatch.c b/src/dispatch.c index 87083a324..67e16357d 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -38,8 +38,6 @@ extern hc_global_data_t data; -extern hc_thread_mutex_t mux_counter; - static void set_kernel_power_final (const u64 kernel_power_final) { if (data.quiet == 0) @@ -179,14 +177,14 @@ void *thread_calc_stdin (void *p) { if ((line_len < data.pw_min) || (line_len > data.pw_max)) { - hc_thread_mutex_lock (mux_counter); + hc_thread_mutex_lock (opencl_ctx->mux_counter); for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { data.words_progress_rejected[salt_pos] += data.kernel_rules_cnt; } - hc_thread_mutex_unlock (mux_counter); + hc_thread_mutex_unlock (opencl_ctx->mux_counter); continue; } @@ -414,14 +412,14 @@ void *thread_calc (void *p) { max++; - hc_thread_mutex_lock (mux_counter); + hc_thread_mutex_lock (opencl_ctx->mux_counter); for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { data.words_progress_rejected[salt_pos] += data.kernel_rules_cnt; } - hc_thread_mutex_unlock (mux_counter); + hc_thread_mutex_unlock (opencl_ctx->mux_counter); continue; } @@ -435,14 +433,14 @@ void *thread_calc (void *p) { max++; - hc_thread_mutex_lock (mux_counter); + hc_thread_mutex_lock (opencl_ctx->mux_counter); for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { data.words_progress_rejected[salt_pos] += data.combs_cnt; } - hc_thread_mutex_unlock (mux_counter); + hc_thread_mutex_unlock (opencl_ctx->mux_counter); continue; } diff --git a/src/hashcat.c b/src/hashcat.c index 7349d6f4b..1ba103394 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -92,7 +92,6 @@ extern int SUPPRESS_OUTPUT; extern hc_thread_mutex_t mux_hwmon; extern hc_thread_mutex_t mux_display; -extern hc_thread_mutex_t mux_counter; extern void (*get_next_word_func) (char *, u32, u32 *, u32 *); @@ -185,7 +184,6 @@ int main (int argc, char **argv) int myargc = argc; char **myargv = argv; - hc_thread_mutex_init (mux_counter); hc_thread_mutex_init (mux_display); hc_thread_mutex_init (mux_hwmon); @@ -5332,7 +5330,6 @@ int main (int argc, char **argv) // destroy others mutex - hc_thread_mutex_delete (mux_counter); hc_thread_mutex_delete (mux_display); hc_thread_mutex_delete (mux_hwmon); diff --git a/src/opencl.c b/src/opencl.c index 7adcd1efc..d52128274 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -40,7 +40,6 @@ extern hc_global_data_t data; -extern hc_thread_mutex_t mux_counter; extern hc_thread_mutex_t mux_hwmon; extern const int comptime; @@ -1252,11 +1251,11 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash u64 perf_sum_all = (u64) pws_cnt * (u64) innerloop_left; - hc_thread_mutex_lock (mux_counter); + hc_thread_mutex_lock (opencl_ctx->mux_counter); data.words_progress_done[salt_pos] += perf_sum_all; - hc_thread_mutex_unlock (mux_counter); + hc_thread_mutex_unlock (opencl_ctx->mux_counter); /** * speed @@ -1314,6 +1313,7 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con } hc_thread_mutex_init (opencl_ctx->mux_dispatcher); + hc_thread_mutex_init (opencl_ctx->mux_counter); opencl_ctx->devices_status = STATUS_INIT; opencl_ctx->run_main_level1 = true; @@ -1500,6 +1500,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx) myfree (opencl_ctx->platform_devices); + hc_thread_mutex_delete (opencl_ctx->mux_counter); hc_thread_mutex_delete (opencl_ctx->mux_dispatcher); myfree (opencl_ctx); diff --git a/src/status.c b/src/status.c index 900e60a44..0341f799f 100644 --- a/src/status.c +++ b/src/status.c @@ -34,7 +34,6 @@ extern hc_global_data_t data; extern hc_thread_mutex_t mux_hwmon; hc_thread_mutex_t mux_display; -hc_thread_mutex_t mux_counter; static void format_timer_display (struct tm *tm, char *buf, size_t len) {