From 53e96a12a0232821e42053b662d4828d0a79f38b Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 16 Nov 2019 11:48:25 +0100 Subject: [PATCH] Improve automatic calculation of hook threads value --- src/backend.c | 13 +++++++++++++ src/hashcat.c | 6 ------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/backend.c b/src/backend.c index c0b7734e0..fb68dbcb7 100644 --- a/src/backend.c +++ b/src/backend.c @@ -6252,6 +6252,19 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) return -1; } + // now we can calculate the number of parallel running hook threads based on + // the number cpu cores and the number of active compute devices + // unless overwritten by the user + + if (user_options->hook_threads == HOOK_THREADS) + { + const u32 processor_count = hc_get_processor_count (); + + const u32 processor_count_cu = CEILDIV (processor_count, backend_ctx->backend_devices_active); // should never reach 0 + + user_options->hook_threads = processor_count_cu; + } + // additional check to see if the user has chosen a device that is not within the range of available devices (i.e. larger than devices_cnt) if (backend_ctx->backend_devices_filter != (u64) -1) diff --git a/src/hashcat.c b/src/hashcat.c index eaf16a24a..01a069ab7 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1043,12 +1043,6 @@ int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder setup_umask (); - /** - * Find number of physical CPU cores - */ - - user_options->hook_threads = hc_get_processor_count (); - /** * tuning db */