From 8abc42e346ca6684c2dda4efb56053c304e384b2 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 13 Jun 2016 23:50:49 +0200 Subject: [PATCH] Simple, but effective workaround to solve the 100% CPU burning loop bug in Nvidias OpenCL runtime, works Linux and Windows, 0% cpu (alsmost), 100% performance in comparison to CPU burning loop variant. Replaces old previous try with overwritten clock_gettime() function --- include/types.h | 1 + src/hashcat.c | 24 +++++++----------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/include/types.h b/include/types.h index 305b982..0a45ec7 100644 --- a/include/types.h +++ b/include/types.h @@ -988,6 +988,7 @@ struct __hc_device_param uint exec_pos; double exec_ms[EXEC_CACHE]; + double exec_prev; // this is "current" speed diff --git a/src/hashcat.c b/src/hashcat.c index ab38fe2..4f6ee58 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -2468,6 +2468,11 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co hc_clFlush (data.ocl, device_param->command_queue); + if (data.devices_status == STATUS_RUNNING) + { + usleep (device_param->exec_prev * 1000); + } + hc_clWaitForEvents (data.ocl, 1, &event); if (event_update) @@ -2484,6 +2489,8 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co device_param->exec_ms[exec_pos] = exec_time; + device_param->exec_prev = exec_time; + exec_pos++; if (exec_pos == EXEC_CACHE) @@ -5425,19 +5432,6 @@ static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, cons * main */ -#ifdef LINUX -int (*clock_gettime_orig) (clockid_t clk_id, struct timespec *tp); - -int clock_gettime (clockid_t clk_id, struct timespec *tp) -{ - int r = clock_gettime_orig (clk_id, tp); - - usleep (NVIDIA_100PERCENTCPU_WORKAROUND); - - return r; -} -#endif - #ifdef WIN void SetConsoleWindowSize (const int x) { @@ -5466,10 +5460,6 @@ void SetConsoleWindowSize (const int x) int main (int argc, char **argv) { - #ifdef LINUX - clock_gettime_orig = dlsym (RTLD_NEXT, "clock_gettime"); - #endif - #ifdef WIN SetConsoleWindowSize (132); #endif -- 2.25.1