mirror of
https://github.com/hashcat/hashcat
synced 2025-01-17 23:17:27 +01:00
OpenCL Runtime: Disable OpenCL kernel cache on Apple for Intel CPU (throws CL_BUILD_PROGRAM_FAILURE for no reason)
This commit is contained in:
parent
84d6b8ecc1
commit
b99d392e78
@ -38,6 +38,7 @@
|
||||
- Tuning Database: Updated hashcat.hctune with new models and refreshed vector width values
|
||||
- Bitcoin Wallet: Be more user friendly by allowing a larger data range for ckey and public_key
|
||||
- OpenCL Runtime: Workaround JiT compiler error on AMDGPU driver compiling WPA-EAPOL-PBKDF2 OpenCL kernel
|
||||
- OpenCL Runtime: Disable OpenCL kernel cache on Apple for Intel CPU (throws CL_BUILD_PROGRAM_FAILURE for no reason)
|
||||
- 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
|
||||
- My Wallet: Added additional plaintext pattern used in newer versions
|
||||
|
@ -9,17 +9,18 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
static const char CL_VENDOR_AMD1[] = "Advanced Micro Devices, Inc.";
|
||||
static const char CL_VENDOR_AMD2[] = "AuthenticAMD";
|
||||
static const char CL_VENDOR_AMD_USE_INTEL[] = "GenuineIntel";
|
||||
static const char CL_VENDOR_APPLE[] = "Apple";
|
||||
static const char CL_VENDOR_APPLE_USE_AMD[] = "AMD";
|
||||
static const char CL_VENDOR_APPLE_USE_NV[] = "NVIDIA";
|
||||
static const char CL_VENDOR_INTEL_BEIGNET[] = "Intel";
|
||||
static const char CL_VENDOR_INTEL_SDK[] = "Intel(R) Corporation";
|
||||
static const char CL_VENDOR_MESA[] = "Mesa";
|
||||
static const char CL_VENDOR_NV[] = "NVIDIA Corporation";
|
||||
static const char CL_VENDOR_POCL[] = "The pocl project";
|
||||
static const char CL_VENDOR_AMD1[] = "Advanced Micro Devices, Inc.";
|
||||
static const char CL_VENDOR_AMD2[] = "AuthenticAMD";
|
||||
static const char CL_VENDOR_AMD_USE_INTEL[] = "GenuineIntel";
|
||||
static const char CL_VENDOR_APPLE[] = "Apple";
|
||||
static const char CL_VENDOR_APPLE_USE_AMD[] = "AMD";
|
||||
static const char CL_VENDOR_APPLE_USE_NV[] = "NVIDIA";
|
||||
static const char CL_VENDOR_APPLE_USE_INTEL[] = "Intel Inc.";
|
||||
static const char CL_VENDOR_INTEL_BEIGNET[] = "Intel";
|
||||
static const char CL_VENDOR_INTEL_SDK[] = "Intel(R) Corporation";
|
||||
static const char CL_VENDOR_MESA[] = "Mesa";
|
||||
static const char CL_VENDOR_NV[] = "NVIDIA Corporation";
|
||||
static const char CL_VENDOR_POCL[] = "The pocl project";
|
||||
|
||||
int ocl_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void ocl_close (hashcat_ctx_t *hashcat_ctx);
|
||||
|
210
src/opencl.c
210
src/opencl.c
@ -3376,6 +3376,10 @@ int opencl_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
{
|
||||
device_vendor_id = VENDOR_ID_NV;
|
||||
}
|
||||
else if (strcmp (device_vendor, CL_VENDOR_APPLE_USE_INTEL) == 0)
|
||||
{
|
||||
device_vendor_id = VENDOR_ID_INTEL_SDK;
|
||||
}
|
||||
else if (strcmp (device_vendor, CL_VENDOR_INTEL_BEIGNET) == 0)
|
||||
{
|
||||
device_vendor_id = VENDOR_ID_INTEL_BEIGNET;
|
||||
@ -4912,6 +4916,28 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%08x", device_name_digest_amp_mp[0]);
|
||||
|
||||
/**
|
||||
* kernel cache
|
||||
*/
|
||||
|
||||
bool cache_disable = false;
|
||||
|
||||
// Seems to be completely broken on Apple + (Intel?) CPU
|
||||
// To reproduce set cache_disable to false and run benchmark -b
|
||||
|
||||
if (device_param->platform_vendor_id == VENDOR_ID_APPLE)
|
||||
{
|
||||
if (device_param->device_type & CL_DEVICE_TYPE_CPU)
|
||||
{
|
||||
cache_disable = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (module_ctx->module_jit_cache_disable != MODULE_DEFAULT)
|
||||
{
|
||||
cache_disable = module_ctx->module_jit_cache_disable (hashconfig, user_options, user_options_extra, hashes, device_param);
|
||||
}
|
||||
|
||||
/**
|
||||
* main kernel
|
||||
*/
|
||||
@ -4942,6 +4968,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
bool cached = true;
|
||||
|
||||
if (cache_disable == true)
|
||||
{
|
||||
cached = false;
|
||||
}
|
||||
|
||||
if (hc_path_read (cached_file) == false)
|
||||
{
|
||||
cached = false;
|
||||
@ -4964,100 +4995,12 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char **kernel_sources = &kernel_sources_buf;
|
||||
|
||||
bool cache_disable = false;
|
||||
|
||||
if (module_ctx->module_jit_cache_disable != MODULE_DEFAULT)
|
||||
if (cached == false)
|
||||
{
|
||||
cache_disable = module_ctx->module_jit_cache_disable (hashconfig, user_options, user_options_extra, hashes, device_param);
|
||||
}
|
||||
#if defined (DEBUG)
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
|
||||
#endif
|
||||
|
||||
if (cache_disable == false)
|
||||
{
|
||||
if (cached == false)
|
||||
{
|
||||
#if defined (DEBUG)
|
||||
if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
|
||||
#endif
|
||||
|
||||
const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true);
|
||||
|
||||
if (rc_read_kernel == false) return -1;
|
||||
|
||||
CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, (const char **) kernel_sources, NULL, &device_param->program);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_options_module_buf, NULL, NULL);
|
||||
|
||||
//if (CL_rc == -1) return -1;
|
||||
|
||||
size_t build_log_size = 0;
|
||||
|
||||
hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size);
|
||||
|
||||
//if (CL_rc == -1) return -1;
|
||||
|
||||
#if defined (DEBUG)
|
||||
if ((build_log_size > 1) || (CL_rc == -1))
|
||||
#else
|
||||
if (CL_rc == -1)
|
||||
#endif
|
||||
{
|
||||
char *build_log = (char *) hcmalloc (build_log_size + 1);
|
||||
|
||||
int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL);
|
||||
|
||||
if (CL_rc_build == -1) return -1;
|
||||
|
||||
puts (build_log);
|
||||
|
||||
hcfree (build_log);
|
||||
}
|
||||
|
||||
if (CL_rc == -1)
|
||||
{
|
||||
device_param->skipped_warning = true;
|
||||
|
||||
event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t binary_size;
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
char *binary = (char *) hcmalloc (binary_size);
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
const bool rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size);
|
||||
|
||||
if (rc_write == false) return -1;
|
||||
|
||||
hcfree (binary);
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false);
|
||||
|
||||
if (rc_read_kernel == false) return -1;
|
||||
|
||||
CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_options_module_buf, NULL, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true);
|
||||
|
||||
if (rc_read_kernel == false) return -1;
|
||||
@ -5101,6 +5044,41 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cache_disable == false)
|
||||
{
|
||||
size_t binary_size;
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
char *binary = (char *) hcmalloc (binary_size);
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
const bool rc_write = write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size);
|
||||
|
||||
if (rc_write == false) return -1;
|
||||
|
||||
hcfree (binary);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false);
|
||||
|
||||
if (rc_read_kernel == false) return -1;
|
||||
|
||||
CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_options_module_buf, NULL, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
}
|
||||
|
||||
hcfree (kernel_sources[0]);
|
||||
@ -5144,6 +5122,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
bool cached = true;
|
||||
|
||||
if (cache_disable == true)
|
||||
{
|
||||
cached = false;
|
||||
}
|
||||
|
||||
if (hc_path_read (cached_file) == false)
|
||||
{
|
||||
cached = false;
|
||||
@ -5216,21 +5199,24 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t binary_size;
|
||||
if (cache_disable == false)
|
||||
{
|
||||
size_t binary_size;
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
char *binary = (char *) hcmalloc (binary_size);
|
||||
char *binary = (char *) hcmalloc (binary_size);
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL);
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size);
|
||||
write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size);
|
||||
|
||||
hcfree (binary);
|
||||
hcfree (binary);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5291,6 +5277,11 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
bool cached = true;
|
||||
|
||||
if (cache_disable == true)
|
||||
{
|
||||
cached = false;
|
||||
}
|
||||
|
||||
if (hc_path_read (cached_file) == false)
|
||||
{
|
||||
cached = false;
|
||||
@ -5363,21 +5354,24 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t binary_size;
|
||||
if (cache_disable == false)
|
||||
{
|
||||
size_t binary_size;
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
char *binary = (char *) hcmalloc (binary_size);
|
||||
char *binary = (char *) hcmalloc (binary_size);
|
||||
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL);
|
||||
CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL);
|
||||
|
||||
if (CL_rc == -1) return -1;
|
||||
if (CL_rc == -1) return -1;
|
||||
|
||||
write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size);
|
||||
write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size);
|
||||
|
||||
hcfree (binary);
|
||||
hcfree (binary);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user