From a86b44a7501569378b148d3999cd07e6fb1fb954 Mon Sep 17 00:00:00 2001 From: Jukka Ojanen Date: Mon, 26 Jul 2021 01:51:19 +0300 Subject: [PATCH] Allow async execution of autotune() and prepare try_run() for async kernel execution --- src/autotune.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/autotune.c b/src/autotune.c index cdeb73553..e8148daf7 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -37,6 +37,23 @@ static double try_run (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par device_param->spin_damp = 0; + if (device_param->is_cuda == true) + { + if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1; + } + + if (device_param->is_hip == true) + { + if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return -1; + } + + if (device_param->is_opencl == true) + { + /*if (hc_clFlush (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1;*/ + + if (hc_clFinish (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1; + } + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) @@ -60,6 +77,23 @@ static double try_run (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 0, kernel_power_try, true, 0); } + if (device_param->is_cuda == true) + { + if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1; + } + + if (device_param->is_hip == true) + { + if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return -1; + } + + if (device_param->is_opencl == true) + { + /*if (hc_clFlush (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1;*/ + + if (hc_clFinish (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1; + } + device_param->spin_damp = spin_damp_sav; const double exec_msec_prev = get_avg_exec_time (device_param, 1); @@ -200,14 +234,14 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param { if (device_param->is_cuda == true) { - CU_rc = hc_cuMemcpyDtoD (hashcat_ctx, device_param->cuda_d_rules_c, device_param->cuda_d_rules, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t)); + CU_rc = hc_cuMemcpyDtoDAsync (hashcat_ctx, device_param->cuda_d_rules_c, device_param->cuda_d_rules, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), device_param->cuda_stream); if (CU_rc == -1) return -1; } if (device_param->is_hip == true) { - HIP_rc = hc_hipMemcpyDtoD (hashcat_ctx, device_param->hip_d_rules_c, device_param->hip_d_rules, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t)); + HIP_rc = hc_hipMemcpyDtoDAsync (hashcat_ctx, device_param->hip_d_rules_c, device_param->hip_d_rules, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), device_param->hip_stream); if (HIP_rc == -1) return -1; }