1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-23 08:38:09 +00:00

Move global mux_dispatcher variable into opencl_ctx_t

This commit is contained in:
jsteube 2016-09-20 13:18:47 +02:00
parent 4cde17aea7
commit 3adbf3d0d5
23 changed files with 46 additions and 43 deletions

View File

@ -16,14 +16,6 @@
#include <windows.h> #include <windows.h>
#endif // _WIN #endif // _WIN
#if defined (_WIN)
typedef HANDLE hc_thread_t;
typedef CRITICAL_SECTION hc_thread_mutex_t;
#elif defined (_POSIX)
typedef pthread_t hc_thread_t;
typedef pthread_mutex_t hc_thread_mutex_t;
#endif
#if defined (_WIN) #if defined (_WIN)
#define hc_thread_create(t,f,a) t = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) &f, a, 0, NULL) #define hc_thread_create(t,f,a) t = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) &f, a, 0, NULL)

View File

@ -45,12 +45,22 @@ typedef uint32_t uint; // we need to get rid of this sooner or later, for consis
// timer // timer
#if defined (_WIN) #if defined (_WIN)
typedef LARGE_INTEGER hc_timer_t; typedef LARGE_INTEGER hc_timer_t;
#elif defined (_POSIX) #elif defined (_POSIX)
typedef struct timeval hc_timer_t; typedef struct timeval hc_timer_t;
#endif #endif
// thread
#if defined (_WIN)
typedef HANDLE hc_thread_t;
typedef CRITICAL_SECTION hc_thread_mutex_t;
#elif defined (_POSIX)
typedef pthread_t hc_thread_t;
typedef pthread_mutex_t hc_thread_mutex_t;
#endif
// enums
typedef enum wl_mode typedef enum wl_mode
{ {
@ -67,7 +77,6 @@ typedef enum hl_mode
} hl_mode_t; } hl_mode_t;
typedef struct typedef struct
{ {
char *file_name; char *file_name;
@ -76,7 +85,6 @@ typedef struct
} outfile_data_t; } outfile_data_t;
typedef enum attack_mode typedef enum attack_mode
{ {
ATTACK_MODE_STRAIGHT = 0, ATTACK_MODE_STRAIGHT = 0,
@ -526,6 +534,8 @@ typedef struct
int force_jit_compilation; int force_jit_compilation;
hc_thread_mutex_t mux_dispatcher;
} opencl_ctx_t; } opencl_ctx_t;
#if defined (__APPLE__) #if defined (__APPLE__)
@ -789,8 +799,6 @@ typedef struct
* threads * threads
*/ */
opencl_ctx_t *opencl_ctx; opencl_ctx_t *opencl_ctx;
u32 shutdown_inner; u32 shutdown_inner;

View File

@ -16,6 +16,7 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"

View File

@ -15,6 +15,7 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"

View File

@ -16,11 +16,11 @@
#include "ext_nvml.h" #include "ext_nvml.h"
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "terminal.h" #include "terminal.h"
#include "mpsp.h" #include "mpsp.h"
@ -40,8 +40,6 @@ extern hc_global_data_t data;
extern hc_thread_mutex_t mux_counter; extern hc_thread_mutex_t mux_counter;
hc_thread_mutex_t mux_dispatcher;
static void set_kernel_power_final (const u64 kernel_power_final) static void set_kernel_power_final (const u64 kernel_power_final)
{ {
if (data.quiet == 0) if (data.quiet == 0)
@ -79,9 +77,9 @@ static u32 get_power (hc_device_param_t *device_param)
return device_param->kernel_power; return device_param->kernel_power;
} }
static uint get_work (hc_device_param_t *device_param, const u64 max) static uint get_work (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const u64 max)
{ {
hc_thread_mutex_lock (mux_dispatcher); hc_thread_mutex_lock (opencl_ctx->mux_dispatcher);
const u64 words_cur = data.words_cur; const u64 words_cur = data.words_cur;
const u64 words_base = (data.limit == 0) ? data.words_base : MIN (data.limit, data.words_base); const u64 words_base = (data.limit == 0) ? data.words_base : MIN (data.limit, data.words_base);
@ -108,7 +106,7 @@ static uint get_work (hc_device_param_t *device_param, const u64 max)
data.words_cur += work; data.words_cur += work;
hc_thread_mutex_unlock (mux_dispatcher); hc_thread_mutex_unlock (opencl_ctx->mux_dispatcher);
return work; return work;
} }
@ -130,11 +128,11 @@ void *thread_calc_stdin (void *p)
while (opencl_ctx->run_thread_level1 == true) while (opencl_ctx->run_thread_level1 == true)
{ {
hc_thread_mutex_lock (mux_dispatcher); hc_thread_mutex_lock (opencl_ctx->mux_dispatcher);
if (feof (stdin) != 0) if (feof (stdin) != 0)
{ {
hc_thread_mutex_unlock (mux_dispatcher); hc_thread_mutex_unlock (opencl_ctx->mux_dispatcher);
break; break;
} }
@ -201,7 +199,7 @@ void *thread_calc_stdin (void *p)
while (opencl_ctx->run_thread_level1 == false) break; while (opencl_ctx->run_thread_level1 == false) break;
} }
hc_thread_mutex_unlock (mux_dispatcher); hc_thread_mutex_unlock (opencl_ctx->mux_dispatcher);
while (opencl_ctx->run_thread_level1 == false) break; while (opencl_ctx->run_thread_level1 == false) break;
@ -257,7 +255,7 @@ void *thread_calc (void *p)
{ {
while (opencl_ctx->run_thread_level1 == true) while (opencl_ctx->run_thread_level1 == true)
{ {
const uint work = get_work (device_param, -1u); const uint work = get_work (opencl_ctx, device_param, -1u);
if (work == 0) break; if (work == 0) break;
@ -371,7 +369,7 @@ void *thread_calc (void *p)
while (max) while (max)
{ {
const uint work = get_work (device_param, max); const uint work = get_work (opencl_ctx, device_param, max);
if (work == 0) break; if (work == 0) break;

View File

@ -17,12 +17,12 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "filehandling.h" #include "filehandling.h"
#include "thread.h"
#include "outfile.h" #include "outfile.h"
#include "potfile.h" #include "potfile.h"
#include "debugfile.h" #include "debugfile.h"

View File

@ -45,11 +45,11 @@
#include "cpu_sha256.h" #include "cpu_sha256.h"
#include "filehandling.h" #include "filehandling.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "locking.h" #include "locking.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "rp_kernel_on_cpu.h" #include "rp_kernel_on_cpu.h"
@ -93,7 +93,6 @@ extern int SUPPRESS_OUTPUT;
extern hc_thread_mutex_t mux_hwmon; extern hc_thread_mutex_t mux_hwmon;
extern hc_thread_mutex_t mux_display; extern hc_thread_mutex_t mux_display;
extern hc_thread_mutex_t mux_counter; extern hc_thread_mutex_t mux_counter;
extern hc_thread_mutex_t mux_dispatcher;
extern void (*get_next_word_func) (char *, u32, u32 *, u32 *); extern void (*get_next_word_func) (char *, u32, u32 *, u32 *);
@ -186,7 +185,6 @@ int main (int argc, char **argv)
int myargc = argc; int myargc = argc;
char **myargv = argv; char **myargv = argv;
hc_thread_mutex_init (mux_dispatcher);
hc_thread_mutex_init (mux_counter); hc_thread_mutex_init (mux_counter);
hc_thread_mutex_init (mux_display); hc_thread_mutex_init (mux_display);
hc_thread_mutex_init (mux_hwmon); hc_thread_mutex_init (mux_hwmon);
@ -5334,7 +5332,6 @@ int main (int argc, char **argv)
// destroy others mutex // destroy others mutex
hc_thread_mutex_delete (mux_dispatcher);
hc_thread_mutex_delete (mux_counter); hc_thread_mutex_delete (mux_counter);
hc_thread_mutex_delete (mux_display); hc_thread_mutex_delete (mux_display);
hc_thread_mutex_delete (mux_hwmon); hc_thread_mutex_delete (mux_hwmon);

View File

@ -19,11 +19,11 @@
#include "ext_nvml.h" #include "ext_nvml.h"
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "filehandling.h" #include "filehandling.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "inc_hash_constants.h" #include "inc_hash_constants.h"

View File

@ -17,11 +17,11 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "outfile.h" #include "outfile.h"
#include "potfile.h" #include "potfile.h"
#include "debugfile.h" #include "debugfile.h"

View File

@ -20,6 +20,7 @@
#include "rp_cpu.h" #include "rp_cpu.h"
#include "mpsp.h" #include "mpsp.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"

View File

@ -17,11 +17,11 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "outfile.h" #include "outfile.h"
#include "potfile.h" #include "potfile.h"
#include "debugfile.h" #include "debugfile.h"

View File

@ -21,11 +21,11 @@
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "filehandling.h" #include "filehandling.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "outfile.h" #include "outfile.h"

View File

@ -22,7 +22,6 @@
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "status.h" #include "status.h"
#include "stdout.h" #include "stdout.h"
#include "mpsp.h" #include "mpsp.h"
@ -1314,6 +1313,8 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con
return 0; return 0;
} }
hc_thread_mutex_init (opencl_ctx->mux_dispatcher);
opencl_ctx->devices_status = STATUS_INIT; opencl_ctx->devices_status = STATUS_INIT;
opencl_ctx->run_main_level1 = true; opencl_ctx->run_main_level1 = true;
opencl_ctx->run_main_level2 = true; opencl_ctx->run_main_level2 = true;
@ -1499,6 +1500,8 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx)
myfree (opencl_ctx->platform_devices); myfree (opencl_ctx->platform_devices);
hc_thread_mutex_delete (opencl_ctx->mux_dispatcher);
myfree (opencl_ctx); myfree (opencl_ctx);
} }

View File

@ -17,6 +17,7 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
@ -29,7 +30,6 @@
#include "status.h" #include "status.h"
#include "convert.h" #include "convert.h"
#include "shared.h" #include "shared.h"
#include "thread.h"
#include "outfile_check.h" #include "outfile_check.h"
extern hc_global_data_t data; extern hc_global_data_t data;

View File

@ -15,11 +15,11 @@
#include "ext_nvml.h" #include "ext_nvml.h"
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "mpsp.h" #include "mpsp.h"
#include "outfile.h" #include "outfile.h"

View File

@ -20,11 +20,11 @@
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "convert.h" #include "convert.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "terminal.h" #include "terminal.h"
#include "mpsp.h" #include "mpsp.h"

View File

@ -15,11 +15,11 @@
#include "ext_nvml.h" #include "ext_nvml.h"
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "terminal.h" #include "terminal.h"
#include "mpsp.h" #include "mpsp.h"

View File

@ -17,11 +17,11 @@
#include "ext_nvml.h" #include "ext_nvml.h"
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "locking.h" #include "locking.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "rp_kernel_on_cpu.h" #include "rp_kernel_on_cpu.h"

View File

@ -16,11 +16,11 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "outfile.h" #include "outfile.h"
#include "potfile.h" #include "potfile.h"
#include "debugfile.h" #include "debugfile.h"

View File

@ -16,11 +16,11 @@
#include "ext_nvml.h" #include "ext_nvml.h"
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "terminal.h" #include "terminal.h"
#include "mpsp.h" #include "mpsp.h"

View File

@ -12,6 +12,7 @@
#include "filehandling.h" #include "filehandling.h"
#include "ext_OpenCL.h" #include "ext_OpenCL.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hash_management.h" #include "hash_management.h"

View File

@ -16,6 +16,7 @@
#include "mpsp.h" #include "mpsp.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"

View File

@ -17,11 +17,11 @@
#include "ext_nvml.h" #include "ext_nvml.h"
#include "ext_xnvctrl.h" #include "ext_xnvctrl.h"
#include "tuningdb.h" #include "tuningdb.h"
#include "thread.h"
#include "opencl.h" #include "opencl.h"
#include "hwmon.h" #include "hwmon.h"
#include "restore.h" #include "restore.h"
#include "hash_management.h" #include "hash_management.h"
#include "thread.h"
#include "locking.h" #include "locking.h"
#include "rp_cpu.h" #include "rp_cpu.h"
#include "rp_kernel_on_cpu.h" #include "rp_kernel_on_cpu.h"