Merge pull request #3058 from matrix/apple_m1_final

Added support to use Apple Silicon compute devices
pull/3064/head
Jens Steube 2 years ago committed by GitHub
commit 8b61f60e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,6 +28,8 @@
- Tuning Database: Added a warning if a module implements module_extra_tuningdb_block but the installed computing device is not found
- Usage Screen: On windows console, wait for any keypress if usage_mini_print() is used
- User Options: Add new module function module_hash_decode_postprocess() to override hash specific configurations from command line
- OpenCL Runtime: Added support to use Apple Silicon compute devices
- OpenCL Runtime: Set default device-type to GPU with Apple Silicon compute devices
* changes v6.2.4 -> v6.2.5

@ -22,6 +22,7 @@ Gabriele "matrix" Gristina <matrix@hashcat.net> (@gm4tr1x)
* Compressed wordlist feature
* OpenCL Info feature
* Apple macOS port
* Apple Silicon support
* Hardware monitor initial code base and maintenance
* Test suite initial code base
* Makefile initial code base

@ -341,11 +341,27 @@ static bool setup_opencl_device_types_filter (hashcat_ctx_t *hashcat_ctx, const
{
#if defined (__APPLE__)
// For apple use CPU only, because GPU drivers are not reliable
// The user can explicitly enable GPU by setting -D2
#include <sys/sysctl.h>
//opencl_device_types_filter = CL_DEVICE_TYPE_ALL & ~CL_DEVICE_TYPE_GPU;
opencl_device_types_filter = CL_DEVICE_TYPE_CPU;
size_t size;
cpu_type_t cpu_type = 0;
size = sizeof (cpu_type);
sysctlbyname ("hw.cputype", &cpu_type, &size, NULL, 0);
if (cpu_type == 0x100000c)
{
// For apple M1* use GPU only, because CPU device it is not recognized by OpenCL
opencl_device_types_filter = CL_DEVICE_TYPE_GPU;
}
else
{
// For apple use CPU only, because GPU drivers are not reliable
// The user can explicitly enable GPU by setting -D2
//opencl_device_types_filter = CL_DEVICE_TYPE_ALL & ~CL_DEVICE_TYPE_GPU;
opencl_device_types_filter = CL_DEVICE_TYPE_CPU;
}
#else
@ -5170,13 +5186,6 @@ int run_opencl_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi
// with apple GPU clEnqueueWriteBuffer() return CL_INVALID_VALUE, workaround
if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE && \
(device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK || device_param->opencl_device_vendor_id == VENDOR_ID_APPLE) && \
device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
{
return run_opencl_kernel_memset (hashcat_ctx, device_param, buf, 0, 0, size);
}
if (num16d)
{
const u64 kernel_threads = device_param->kernel_wgs_bzero;
@ -5196,7 +5205,20 @@ int run_opencl_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi
if (num16m)
{
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, buf, CL_FALSE, num16d * 16, num16m, bzeros, 0, NULL, NULL) == -1) return -1;
if (device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE && \
(device_param->opencl_device_vendor_id == VENDOR_ID_INTEL_SDK || device_param->opencl_device_vendor_id == VENDOR_ID_APPLE) && \
device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
{
u8 *bzeros_apple = (u8 *) hccalloc (num16m, sizeof (u8));
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, buf, CL_TRUE, num16d * 16, num16m, bzeros_apple, 0, NULL, NULL) == -1) return -1;
hcfree (bzeros_apple);
}
else
{
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, buf, CL_FALSE, num16d * 16, num16m, bzeros, 0, NULL, NULL) == -1) return -1;
}
}
return 0;
@ -10535,7 +10557,7 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
// workaround opencl issue with Apple Silicon
if (strcmp (device_param->device_name, "Apple M") != 0)
if (strncmp (device_param->device_name, "Apple M", 7) == 0)
{
if (hc_clCreateProgramWithSource (hashcat_ctx, device_param->opencl_context, 1, (const char **) kernel_sources, NULL, opencl_program) == -1) return false;
@ -10562,7 +10584,7 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
int rc_clGetProgramBuildInfo;
if (strcmp (device_param->device_name, "Apple M") != 0)
if (strncmp (device_param->device_name, "Apple M", 7) == 0)
{
rc_clGetProgramBuildInfo = hc_clGetProgramBuildInfo (hashcat_ctx, *opencl_program, device_param->opencl_device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL);
}
@ -10589,10 +10611,7 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
// workaround opencl issue with Apple Silicon
if (strcmp (device_param->device_name, "Apple M") != 0)
{
}
else
if (strncmp (device_param->device_name, "Apple M", 7) != 0)
{
cl_program t2[1];

Loading…
Cancel
Save