From 1f442b5b0c0ccc27c0c47b858836950a04e06510 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 11 Feb 2018 16:09:50 +0100 Subject: [PATCH] Add get_kernel_local_mem_size() for future use --- include/types.h | 17 ++++++++ src/opencl.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/include/types.h b/include/types.h index 32baedd1d..21985bf93 100644 --- a/include/types.h +++ b/include/types.h @@ -951,6 +951,23 @@ typedef struct hc_device_param u32 kernel_threads_by_wgs_kernel_atinit; u32 kernel_threads_by_wgs_kernel_decompress; + u64 kernel_local_mem_size1; + u64 kernel_local_mem_size12; + u64 kernel_local_mem_size2; + u64 kernel_local_mem_size23; + u64 kernel_local_mem_size3; + u64 kernel_local_mem_size4; + u64 kernel_local_mem_size_init2; + u64 kernel_local_mem_size_loop2; + u64 kernel_local_mem_size_mp; + u64 kernel_local_mem_size_mp_l; + u64 kernel_local_mem_size_mp_r; + u64 kernel_local_mem_size_amp; + u64 kernel_local_mem_size_tm; + u64 kernel_local_mem_size_memset; + u64 kernel_local_mem_size_atinit; + u64 kernel_local_mem_size_decompress; + u32 kernel_accel; u32 kernel_accel_prev; u32 kernel_accel_min; diff --git a/src/opencl.c b/src/opencl.c index 1f1867b0d..3dd276618 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -3864,6 +3864,23 @@ void opencl_ctx_devices_kernel_loops (hashcat_ctx_t *hashcat_ctx) } } +static int get_kernel_local_mem_size (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_kernel kernel, u64 *result) +{ + int CL_rc; + + cl_ulong local_mem_size; + + CL_rc = hc_clGetKernelWorkGroupInfo (hashcat_ctx, kernel, device_param->device, CL_KERNEL_LOCAL_MEM_SIZE, sizeof (local_mem_size), &local_mem_size, NULL); + + if (CL_rc == -1) return -1; + +printf ("%zu\n", local_mem_size); + + *result = local_mem_size; + + return 0; +} + static int get_kernel_threads (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_kernel kernel, u32 *result) { int CL_rc; @@ -5445,6 +5462,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel1, &device_param->kernel_local_mem_size1); + + if (CL_rc == -1) return -1; + // kernel2 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 8); @@ -5457,6 +5478,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel2, &device_param->kernel_local_mem_size2); + + if (CL_rc == -1) return -1; + // kernel3 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_s%02d", hashconfig->kern_type, 16); @@ -5468,6 +5493,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel3, &device_param->kernel_threads_by_wgs_kernel3); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel3, &device_param->kernel_local_mem_size3); + + if (CL_rc == -1) return -1; } else { @@ -5480,6 +5509,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel4, &device_param->kernel_threads_by_wgs_kernel4); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel4, &device_param->kernel_local_mem_size4); + + if (CL_rc == -1) return -1; } } else @@ -5498,6 +5531,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel1, &device_param->kernel_local_mem_size1); + + if (CL_rc == -1) return -1; + // kernel2 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 8); @@ -5510,6 +5547,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel2, &device_param->kernel_local_mem_size2); + + if (CL_rc == -1) return -1; + // kernel3 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_m%02d", hashconfig->kern_type, 16); @@ -5521,6 +5562,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel3, &device_param->kernel_threads_by_wgs_kernel3); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel3, &device_param->kernel_local_mem_size3); + + if (CL_rc == -1) return -1; } else { @@ -5533,6 +5578,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel4, &device_param->kernel_threads_by_wgs_kernel4); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel4, &device_param->kernel_local_mem_size4); + + if (CL_rc == -1) return -1; } } @@ -5549,6 +5598,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_threads_by_wgs_kernel_tm); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_local_mem_size_tm); + + if (CL_rc == -1) return -1; } } } @@ -5566,6 +5619,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel1, &device_param->kernel_local_mem_size1); + + if (CL_rc == -1) return -1; + // kernel2 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_loop", hashconfig->kern_type); @@ -5578,6 +5635,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel2, &device_param->kernel_local_mem_size2); + + if (CL_rc == -1) return -1; + // kernel3 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_comp", hashconfig->kern_type); @@ -5590,6 +5651,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel3, &device_param->kernel_local_mem_size3); + + if (CL_rc == -1) return -1; + // kernel12 if (hashconfig->opts_type & OPTS_TYPE_HOOK12) @@ -5603,6 +5668,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel12, &device_param->kernel_threads_by_wgs_kernel12); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel12, &device_param->kernel_local_mem_size12); + + if (CL_rc == -1) return -1; } // kernel23 @@ -5618,6 +5687,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel23, &device_param->kernel_threads_by_wgs_kernel23); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel23, &device_param->kernel_local_mem_size23); + + if (CL_rc == -1) return -1; } // init2 @@ -5633,6 +5706,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel_init2, &device_param->kernel_threads_by_wgs_kernel_init2); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_init2, &device_param->kernel_local_mem_size_init2); + + if (CL_rc == -1) return -1; } // loop2 @@ -5648,6 +5725,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel_loop2, &device_param->kernel_threads_by_wgs_kernel_loop2); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_loop2, &device_param->kernel_local_mem_size_loop2); + + if (CL_rc == -1) return -1; } } @@ -5661,6 +5742,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_memset, &device_param->kernel_local_mem_size_memset); + + if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 0, sizeof (cl_mem), device_param->kernel_params_memset[0]); if (CL_rc == -1) return -1; CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 1, sizeof (cl_uint), device_param->kernel_params_memset[1]); if (CL_rc == -1) return -1; CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_memset, 2, sizeof (cl_ulong), device_param->kernel_params_memset[2]); if (CL_rc == -1) return -1; @@ -5675,6 +5760,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_atinit, &device_param->kernel_local_mem_size_atinit); + + if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_atinit, 0, sizeof (cl_mem), device_param->kernel_params_atinit[0]); if (CL_rc == -1) return -1; CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_atinit, 1, sizeof (cl_ulong), device_param->kernel_params_atinit[1]); if (CL_rc == -1) return -1; @@ -5688,6 +5777,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_decompress, &device_param->kernel_local_mem_size_decompress); + + if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_decompress, 0, sizeof (cl_mem), device_param->kernel_params_decompress[0]); if (CL_rc == -1) return -1; CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_decompress, 1, sizeof (cl_mem), device_param->kernel_params_decompress[1]); if (CL_rc == -1) return -1; CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_decompress, 2, sizeof (cl_mem), device_param->kernel_params_decompress[2]); if (CL_rc == -1) return -1; @@ -5707,6 +5800,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp_l, &device_param->kernel_local_mem_size_mp_l); + + if (CL_rc == -1) return -1; + // mp_r CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "r_markov", &device_param->kernel_mp_r); @@ -5717,6 +5814,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp_r, &device_param->kernel_local_mem_size_mp_r); + + if (CL_rc == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); if (CL_rc == -1) return -1; @@ -5732,6 +5833,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_threads_by_wgs_kernel_mp); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_local_mem_size_mp); + + if (CL_rc == -1) return -1; } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { @@ -5742,6 +5847,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_threads_by_wgs_kernel_mp); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_local_mem_size_mp); + + if (CL_rc == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -5757,6 +5866,10 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) CL_rc = get_kernel_threads (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_threads_by_wgs_kernel_amp); if (CL_rc == -1) return -1; + + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_local_mem_size_amp); + + if (CL_rc == -1) return -1; } if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)