From d275772b9f6abe92fb33ca620e2967406667bb4e Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 14 Jun 2016 09:17:03 +0200 Subject: [PATCH] Fix for 100% CPU burning loop workaround for slow hashes --- include/types.h | 7 ++++++- src/hashcat.c | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/include/types.h b/include/types.h index 0a45ec7..85a9903 100644 --- a/include/types.h +++ b/include/types.h @@ -988,7 +988,12 @@ struct __hc_device_param uint exec_pos; double exec_ms[EXEC_CACHE]; - double exec_prev; + + // workaround cpu spinning + + double exec_us_prev1; + double exec_us_prev2; + double exec_us_prev3; // this is "current" speed diff --git a/src/hashcat.c b/src/hashcat.c index 4f6ee58..6ffa4db 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -2470,26 +2470,39 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co if (data.devices_status == STATUS_RUNNING) { - usleep (device_param->exec_prev * 1000); + switch (kern_run) + { + case KERN_RUN_1: usleep (device_param->exec_us_prev1); break; + case KERN_RUN_2: usleep (device_param->exec_us_prev2); break; + case KERN_RUN_3: usleep (device_param->exec_us_prev3); break; + } } hc_clWaitForEvents (data.ocl, 1, &event); - if (event_update) - { - cl_ulong time_start; - cl_ulong time_end; + cl_ulong time_start; + cl_ulong time_end; - hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); - hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); + hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_START, sizeof (time_start), &time_start, NULL); + hc_clGetEventProfilingInfo (data.ocl, event, CL_PROFILING_COMMAND_END, sizeof (time_end), &time_end, NULL); - const double exec_time = (double) (time_end - time_start) / 1000000.0; + const double exec_us = (double) (time_end - time_start) / 1000; - uint exec_pos = device_param->exec_pos; + if (data.devices_status == STATUS_RUNNING) + { + switch (kern_run) + { + case KERN_RUN_1: device_param->exec_us_prev1 = exec_us; break; + case KERN_RUN_2: device_param->exec_us_prev2 = exec_us; break; + case KERN_RUN_3: device_param->exec_us_prev3 = exec_us; break; + } + } - device_param->exec_ms[exec_pos] = exec_time; + if (event_update) + { + uint exec_pos = device_param->exec_pos; - device_param->exec_prev = exec_time; + device_param->exec_ms[exec_pos] = exec_us / 1000; exec_pos++; @@ -3120,6 +3133,10 @@ static void autotune (hc_device_param_t *device_param) memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double)); + device_param->exec_us_prev1 = 0; + device_param->exec_us_prev2 = 0; + device_param->exec_us_prev3 = 0; + // store device_param->kernel_accel = kernel_accel; -- 2.25.1