diff --git a/include/opencl.h b/include/opencl.h index 4bb6d4aeb..43d829be4 100644 --- a/include/opencl.h +++ b/include/opencl.h @@ -35,13 +35,14 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt); -int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options); -void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx); +int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options); +void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx); -int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options); +int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options); void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx); +void opencl_ctx_devices_reset (opencl_ctx_t *opencl_ctx); -int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const rules_ctx_t *rules_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db); -int opencl_session_destroy (opencl_ctx_t *opencl_ctx); +int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const rules_ctx_t *rules_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db); +int opencl_session_destroy (opencl_ctx_t *opencl_ctx); #endif // _OPENCL_H diff --git a/src/hashcat.c b/src/hashcat.c index 2bd358e5e..fbf149660 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1205,35 +1205,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user data.kernel_power_final = 0; - for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; - - if (device_param->skipped) continue; - - device_param->speed_pos = 0; - - memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64)); - memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (double)); - - device_param->exec_pos = 0; - - memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double)); - - device_param->outerloop_pos = 0; - device_param->outerloop_left = 0; - device_param->innerloop_pos = 0; - device_param->innerloop_left = 0; - - // some more resets: - - if (device_param->pws_buf) memset (device_param->pws_buf, 0, device_param->size_pws); - - device_param->pws_cnt = 0; - - device_param->words_off = 0; - device_param->words_done = 0; - } + opencl_ctx_devices_reset (opencl_ctx); // figure out some workload diff --git a/src/opencl.c b/src/opencl.c index 41b3ebdd6..e8cbaaa9b 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -2457,6 +2457,39 @@ void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx) opencl_ctx->need_xnvctrl = 0; } +void opencl_ctx_devices_reset (opencl_ctx_t *opencl_ctx) +{ + for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; + + if (device_param->skipped) continue; + + device_param->speed_pos = 0; + + memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64)); + memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (double)); + + device_param->exec_pos = 0; + + memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double)); + + device_param->outerloop_pos = 0; + device_param->outerloop_left = 0; + device_param->innerloop_pos = 0; + device_param->innerloop_left = 0; + + // some more resets: + + if (device_param->pws_buf) memset (device_param->pws_buf, 0, device_param->size_pws); + + device_param->pws_cnt = 0; + + device_param->words_off = 0; + device_param->words_done = 0; + } +} + int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const rules_ctx_t *rules_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db) { /**