From fef18965c3601bf30d1acd6877e0d0f9ff872da7 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 13 Aug 2021 16:00:32 +0200 Subject: [PATCH 1/2] workaround to 'clEnqueueWriteBuffer(): CL_INVALID_VALUE' with apple gpu --- src/backend.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index 3f1a91362..8a7ab97d8 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5175,7 +5175,23 @@ 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; + // with apple GPU clEnqueueWriteBuffer() return CL_INVALID_VALUE + // following a 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) + { + 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; From 72735ed7c418f2d692ce869e99a702cf5961a7ca Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 13 Aug 2021 20:17:09 +0200 Subject: [PATCH 2/2] update workaround --- src/backend.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/backend.c b/src/backend.c index 8a7ab97d8..b075d912d 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5156,6 +5156,15 @@ int run_opencl_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi const u64 num16d = size / 16; const u64 num16m = size % 16; + // 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; @@ -5175,23 +5184,7 @@ int run_opencl_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi if (num16m) { - // with apple GPU clEnqueueWriteBuffer() return CL_INVALID_VALUE - // following a 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) - { - 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; - } + 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;