From ccacc508cb08d2a2b5592df0e85203e4d3a45e6a Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Fri, 24 Jan 2020 10:52:12 +0100 Subject: [PATCH] Reenabled support for Intel GPU OpenCL runtime (Beignet and NEO) because a workaround was found (force -cl-std=CL2.0) --- docs/changes.txt | 2 +- include/types.h | 5 ++++ src/backend.c | 53 ++++++++++++++++++++++++++++++-------- src/modules/module_08000.c | 9 +++---- src/modules/module_21800.c | 9 +++---- 5 files changed, 54 insertions(+), 24 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 8436120af..beb33943f 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -107,7 +107,7 @@ - OpenCL Runtime: Do not run shared- and constant-memory size checks if their memory type is of type global memory (typically CPU) - OpenCL Runtime: Improve ROCm detection and make sure to not confuse with recent AMDGPU drivers - OpenCL Runtime: Not using amd_bytealign (amd_bitalign is fine) on AMDGPU driver drastically reduces JiT segfaults -- OpenCL Runtime: Reenabled support for Intel GPU OpenCL runtime +- OpenCL Runtime: Reenabled support for Intel GPU OpenCL runtime (Beignet and NEO) because a workaround was found (force -cl-std=CL2.0) - OpenCL Runtime: Unlocked maximum thread count - OpenCL Runtime: Update unstable mode warnings for Apple and AMDGPU drivers - OpenCL Runtime: Workaround JiT compiler error on AMDGPU driver compiling WPA-EAPOL-PBKDF2 OpenCL kernel diff --git a/include/types.h b/include/types.h index 099cdb19c..448b94699 100644 --- a/include/types.h +++ b/include/types.h @@ -1242,6 +1242,11 @@ typedef struct hc_device_param hc_timer_t timer_speed; + // Some more attributes + + bool use_opencl12; + bool use_opencl20; + // AMD bool has_vadd; bool has_vaddc; diff --git a/src/backend.c b/src/backend.c index 3204e7968..4961a773f 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5242,6 +5242,11 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->is_cuda = true; + device_param->is_opencl = false; + + device_param->use_opencl12 = false; + device_param->use_opencl20 = false; + // device_name char *device_name = (char *) hcmalloc (HCBUFSIZ_TINY); @@ -5550,8 +5555,13 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) //device_param->opencl_platform = opencl_platform; + device_param->is_cuda = false; + device_param->is_opencl = true; + device_param->use_opencl12 = false; + device_param->use_opencl20 = false; + size_t param_value_size = 0; // opencl_device_type @@ -5665,6 +5675,23 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->opencl_device_c_version = opencl_device_c_version; + // check OpenCL version + + int opencl_version_min = 0; + int opencl_version_maj = 0; + + if (sscanf (opencl_device_c_version, "OpenCL C %d.%d", &opencl_version_min, &opencl_version_maj) == 2) + { + if ((opencl_version_min == 1) && (opencl_version_maj == 2)) + { + device_param->use_opencl12 = true; + } + else if ((opencl_version_min == 2) && (opencl_version_maj == 0)) + { + device_param->use_opencl20 = true; + } + } + // max_compute_units cl_uint device_processors = 0; @@ -6142,17 +6169,6 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) if (user_options->quiet == false) event_log_warning (hashcat_ctx, " To disable the timeout, see: https://hashcat.net/q/timeoutpatch"); } } - - if ((strstr (device_param->opencl_device_c_version, "beignet")) || (strstr (device_param->opencl_device_version, "beignet"))) - { - event_log_error (hashcat_ctx, "* Device #%u: Intel beignet driver detected!", device_id + 1); - - event_log_warning (hashcat_ctx, "The beignet driver has been marked as likely to fail kernel compilation."); - event_log_warning (hashcat_ctx, "You can use --force to override this, but do not report related errors."); - event_log_warning (hashcat_ctx, NULL); - - return -1; - } } } @@ -7147,6 +7163,21 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -I OpenCL -I %s ", folder_config->cpath_real); #endif + // workarounds reproduceable bugs on some OpenCL runtimes (Beignet and NEO) + // ex: remove empty code in m04, m08 and m16 in OpenCL/m05600_a3-optimized.cl will break s04 kernel (not cracking anymore) + + if (device_param->is_opencl == true) + { + if (device_param->use_opencl12 == true) + { + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-cl-std=CL1.2 "); + } + else if (device_param->use_opencl20 == true) + { + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-cl-std=CL2.0 "); + } + } + // we don't have sm_* on vendors not NV but it doesn't matter #if defined (DEBUG) diff --git a/src/modules/module_08000.c b/src/modules/module_08000.c index 7d420fc90..9ac33a4a5 100644 --- a/src/modules/module_08000.c +++ b/src/modules/module_08000.c @@ -58,13 +58,10 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) { - // self-test failed - if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) - { - return true; - } + return true; } return false; diff --git a/src/modules/module_21800.c b/src/modules/module_21800.c index be304d205..1bb067efc 100644 --- a/src/modules/module_21800.c +++ b/src/modules/module_21800.c @@ -96,13 +96,10 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param) { - if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) + // self-test failed + if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) { - // self-test failed - if ((device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)) - { - return true; - } + return true; } // hangs somewhere in zlib inflate