X-Git-Url: https://www.flypig.org.uk/git/?a=blobdiff_plain;f=src%2FoclHashcat.c;h=e718e9b45a40f1502aff09751170a12e481c9ec5;hb=9294aaccae5ce4623fa7dfa86c95eeb832f8c4cb;hp=36f7753d3985e249820bc9f35cf421f3a333001c;hpb=d9889727e650fb30497be26b03f51d69cdf9657c;p=hashcat.git diff --git a/src/oclHashcat.c b/src/oclHashcat.c index 36f7753..e718e9b 100644 --- a/src/oclHashcat.c +++ b/src/oclHashcat.c @@ -33,7 +33,7 @@ double TARGET_MS_PROFILE[3] = { 8, 16, 96 }; #define MARKOV_DISABLE 0 #define MARKOV_CLASSIC 0 #define BENCHMARK 0 -#define BENCHMARK_REPEATS 2 +#define BENCHMARK_REPEATS 100 #define RESTORE 0 #define RESTORE_TIMER 60 #define RESTORE_DISABLE 0 @@ -802,17 +802,11 @@ void status_display_automat () if (device_param->skipped) continue; - u64 speed_cnt = 0; - float speed_ms = 0; + u64 speed_cnt = 0; + double speed_ms = 0; for (int i = 0; i < SPEED_CACHE; i++) { - float rec_ms; - - hc_timer_get (device_param->speed_rec[i], rec_ms); - - if (rec_ms > SPEED_MAXAGE) continue; - speed_cnt += device_param->speed_cnt[i]; speed_ms += device_param->speed_ms[i]; } @@ -1142,8 +1136,8 @@ void status_display () * speed new */ - u64 speed_cnt[DEVICES_MAX] = { 0 }; - float speed_ms[DEVICES_MAX] = { 0 }; + u64 speed_cnt[DEVICES_MAX] = { 0 }; + double speed_ms[DEVICES_MAX] = { 0 }; for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { @@ -1151,25 +1145,11 @@ void status_display () if (device_param->skipped) continue; - // we need to clear values (set to 0) because in case the device does - // not get new candidates it idles around but speed display would - // show it as working. - // if we instantly set it to 0 after reading it happens that the - // speed can be shown as zero if the users refreshes too fast. - // therefore, we add a timestamp when a stat was recorded and if its - // too old we will not use it - speed_cnt[device_id] = 0; speed_ms[device_id] = 0; for (int i = 0; i < SPEED_CACHE; i++) { - float rec_ms; - - hc_timer_get (device_param->speed_rec[i], rec_ms); - - if (rec_ms > SPEED_MAXAGE) continue; - speed_cnt[device_id] += device_param->speed_cnt[i]; speed_ms[device_id] += device_param->speed_ms[i]; } @@ -1219,15 +1199,15 @@ void status_display () * timers */ - float ms_running = 0; + double ms_running = 0; hc_timer_get (data.timer_running, ms_running); - float ms_paused = data.ms_paused; + double ms_paused = data.ms_paused; if (data.devices_status == STATUS_PAUSED) { - float ms_paused_tmp = 0; + double ms_paused_tmp = 0; hc_timer_get (data.timer_paused, ms_paused_tmp); @@ -1474,7 +1454,7 @@ void status_display () } } - float ms_real = ms_running - ms_paused; + double ms_real = ms_running - ms_paused; float cpt_avg_min = (float) data.cpt_total / ((ms_real / 1000) / 60); float cpt_avg_hour = (float) data.cpt_total / ((ms_real / 1000) / 3600); @@ -1628,13 +1608,13 @@ void status_display () static void status_benchmark () { - if (data.devices_status == STATUS_INIT) return; + if (data.devices_status == STATUS_INIT) return; if (data.devices_status == STATUS_STARTING) return; if (data.words_cnt == 0) return; - u64 speed_cnt[DEVICES_MAX] = { 0 }; - float speed_ms[DEVICES_MAX] = { 0 }; + u64 speed_cnt[DEVICES_MAX] = { 0 }; + double speed_ms[DEVICES_MAX] = { 0 }; for (uint device_id = 0; device_id < data.devices_cnt; device_id++) { @@ -1642,17 +1622,8 @@ static void status_benchmark () if (device_param->skipped) continue; - speed_cnt[device_id] = 0; - speed_ms[device_id] = 0; - - for (int i = 0; i < SPEED_CACHE; i++) - { - speed_cnt[device_id] += device_param->speed_cnt[i]; - speed_ms[device_id] += device_param->speed_ms[i]; - } - - speed_cnt[device_id] /= SPEED_CACHE; - speed_ms[device_id] /= SPEED_CACHE; + speed_cnt[device_id] = device_param->speed_cnt[0]; + speed_ms[device_id] = device_param->speed_ms[0]; } float hashes_all_ms = 0; @@ -2467,7 +2438,7 @@ static void run_kernel (const uint kern_run, hc_device_param_t *device_param, co if (event_update) { - float exec_time; + double exec_time; hc_timer_get (timer, exec_time); @@ -2705,6 +2676,24 @@ static void choose_kernel (hc_device_param_t *device_param, const uint attack_ex if (data.devices_status == STATUS_CRACKED) break; if (data.devices_status == STATUS_ABORTED) break; if (data.devices_status == STATUS_QUIT) break; + + /** + * speed + */ + + const float iter_part = (float) (loop_pos + loop_left) / iter; + + const u64 perf_sum_all = pws_cnt * iter_part; + + double speed_ms; + + hc_timer_get (device_param->timer_speed, speed_ms); + + const u32 speed_pos = device_param->speed_pos; + + device_param->speed_cnt[speed_pos] = perf_sum_all; + + device_param->speed_ms[speed_pos] = speed_ms; } if (opts_type & OPTS_TYPE_HOOK23) @@ -3305,9 +3294,34 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt) if (data.benchmark == 1) { - for (u32 i = 0; i < data.benchmark_repeats; i++) + double exec_ms_avg_prev = get_avg_exec_time (device_param, EXEC_CACHE); + + // a few caching rounds + + for (u32 i = 0; i < 2; i++) { + hc_timer_set (&device_param->timer_speed); + choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt); + + double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); + + exec_ms_avg_prev = exec_ms_avg; + } + + // benchmark_repeats became a maximum possible repeats + + for (u32 i = 2; i < data.benchmark_repeats; i++) + { + hc_timer_set (&device_param->timer_speed); + + choose_kernel (device_param, data.attack_exec, data.attack_mode, data.opts_type, salt_buf, highest_pw_len, pws_cnt); + + double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); + + if ((exec_ms_avg_prev / exec_ms_avg) < 1.001) break; + + exec_ms_avg_prev = exec_ms_avg; } } @@ -3333,11 +3347,6 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt) u64 perf_sum_all = (u64) pws_cnt * (u64) innerloop_left; - if (data.benchmark == 1) - { - perf_sum_all = (perf_sum_all * data.benchmark_repeats) + perf_sum_all; - } - hc_thread_mutex_lock (mux_counter); data.words_progress_done[salt_pos] += perf_sum_all; @@ -3348,7 +3357,7 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt) * speed */ - float speed_ms; + double speed_ms; hc_timer_get (device_param->timer_speed, speed_ms); @@ -3356,12 +3365,12 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt) hc_thread_mutex_lock (mux_display); + // current speed + device_param->speed_cnt[speed_pos] = perf_sum_all; device_param->speed_ms[speed_pos] = speed_ms; - device_param->speed_rec[speed_pos] = device_param->timer_speed; - hc_thread_mutex_unlock (mux_display); speed_pos++; @@ -11404,7 +11413,8 @@ int main (int argc, char **argv) switch (hash_mode) { - case 1500: hashes_buf[0].salt->salt_len = 2; + case 1500: hashes_buf[0].salt->salt_len = 2; + hashes_buf[0].salt->salt_buf[0] = 388; // pure magic break; case 1731: hashes_buf[0].salt->salt_len = 4; break; @@ -12691,6 +12701,49 @@ int main (int argc, char **argv) hc_clGetDeviceIDs (data.ocl, platform, CL_DEVICE_TYPE_ALL, DEVICES_MAX, platform_devices, &platform_devices_cnt); + char platform_vendor[INFOSZ] = { 0 }; + + hc_clGetPlatformInfo (data.ocl, platform, CL_PLATFORM_VENDOR, sizeof (platform_vendor), platform_vendor, NULL); + + // find our own platform vendor because pocl and mesa are pushing original vendor_id through opencl + // this causes trouble with vendor id based macros + // we'll assign generic to those without special optimization available + + cl_uint vendor_id = 0; + + if (strcmp (platform_vendor, CL_VENDOR_AMD) == 0) + { + vendor_id = VENDOR_ID_AMD; + } + else if (strcmp (platform_vendor, CL_VENDOR_APPLE) == 0) + { + vendor_id = VENDOR_ID_GENERIC; + } + else if (strcmp (platform_vendor, CL_VENDOR_INTEL_BEIGNET) == 0) + { + vendor_id = VENDOR_ID_GENERIC; + } + else if (strcmp (platform_vendor, CL_VENDOR_INTEL_SDK) == 0) + { + vendor_id = VENDOR_ID_GENERIC; + } + else if (strcmp (platform_vendor, CL_VENDOR_MESA) == 0) + { + vendor_id = VENDOR_ID_GENERIC; + } + else if (strcmp (platform_vendor, CL_VENDOR_NV) == 0) + { + vendor_id = VENDOR_ID_NV; + } + else if (strcmp (platform_vendor, CL_VENDOR_POCL) == 0) + { + vendor_id = VENDOR_ID_GENERIC; + } + else + { + vendor_id = VENDOR_ID_GENERIC; + } + for (uint platform_devices_id = 0; platform_devices_id < platform_devices_cnt; platform_devices_id++) { size_t param_value_size = 0; @@ -12699,6 +12752,8 @@ int main (int argc, char **argv) hc_device_param_t *device_param = &data.devices_param[device_id]; + device_param->vendor_id = vendor_id; + device_param->device = platform_devices[platform_devices_id]; device_param->device_id = device_id; @@ -12715,14 +12770,6 @@ int main (int argc, char **argv) device_param->device_type = device_type; - // vendor_id - - cl_uint vendor_id = 0; - - hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_VENDOR_ID, sizeof (vendor_id), &vendor_id, NULL); - - device_param->vendor_id = vendor_id; - // device_name hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_NAME, 0, NULL, ¶m_value_size); @@ -12759,16 +12806,6 @@ int main (int argc, char **argv) myfree (device_opencl_version); - if (strstr (device_version, "pocl")) - { - // pocl returns the real vendor_id in CL_DEVICE_VENDOR_ID which causes many problems because of hms and missing amd_bfe () etc - // we need to overwrite vendor_id to avoid this. maybe open pocl issue? - - cl_uint vendor_id = VENDOR_ID_GENERIC; - - device_param->vendor_id = vendor_id; - } - // vector_width cl_uint vector_width; @@ -12951,31 +12988,9 @@ int main (int argc, char **argv) if (device_param->skipped == 0) { - if (strstr (device_version, "pocl")) - { - if (force == 0) - { - log_info (""); - log_info ("ATTENTION! All pocl drivers are known to be broken due to broken LLVM <= 3.7"); - log_info ("You are STRONGLY encouraged not to use it"); - log_info ("You can use --force to override this but do not post error reports if you do so"); - log_info (""); - - return (-1); - } - } - if (device_type & CL_DEVICE_TYPE_GPU) { - if (vendor_id == VENDOR_ID_NV) - { - if (device_param->kernel_exec_timeout != 0) - { - if (data.quiet == 0) log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); - if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); - } - } - else if (vendor_id == VENDOR_ID_AMD) + if (vendor_id == VENDOR_ID_AMD) { int catalyst_check = (force == 1) ? 0 : 1; @@ -13020,6 +13035,27 @@ int main (int argc, char **argv) log_info ("You can use --force to override this but do not post error reports if you do so"); log_info (""); + return (-1); + } + } + else if (vendor_id == VENDOR_ID_NV) + { + if (device_param->kernel_exec_timeout != 0) + { + if (data.quiet == 0) log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1); + if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch"); + } + } + else if (vendor_id == VENDOR_ID_POCL) + { + if (force == 0) + { + log_info (""); + log_info ("ATTENTION! All pocl drivers are known to be broken due to broken LLVM <= 3.7"); + log_info ("You are STRONGLY encouraged not to use it"); + log_info ("You can use --force to override this but do not post error reports if you do so"); + log_info (""); + return (-1); } } @@ -14810,7 +14846,7 @@ int main (int argc, char **argv) if (data.quiet == 0) log_info (""); /** - * Inform user which algorithm is checked and at which workload setting + * In benchmark-mode, inform user which algorithm is checked */ if (benchmark == 1) @@ -16038,8 +16074,7 @@ int main (int argc, char **argv) device_param->speed_pos = 0; memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64)); - memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float)); - memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t)); + memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (double)); device_param->exec_pos = 0;