mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-31 10:58:49 +00:00
Metal Backend: improved memory management
Until now, support for Metal has been written using an Apple M1 and a 10-year-old Apple Intel as a basis to verify that the changes were also compatible with very old devices. Recently, the code has been tested on an Apple M4 Pro, with a performance increase of about 3,7 times compared to the M1. The code has also been sporadically tested on an Apple device with a discrete AMD GPU, but the performance was very low. With this patch, I revisited memory management on Metal, initially creating an easily configurable array mapped 1 to 1 with the buffers allocated by hashcat. The configuration refers to the Storage Mode associated with the buffers, as well as an ad hoc modification that transforms buffers with a SHARED Storage Mode to MANAGED if the device is a discrete GPU and not an M* (Silicon) or integrated (Intel) one. The result was excellent, as some very quick tests showed, for example, argon2 going from 10 H/s (1330.58ms) to 465 H/s (57.26ms)! A 4550% increase in computational power and a 2223% increase in execution timing on the GPU! In addition to the array for configuring the buffer storage modes, a macro, HC_MTL_CREATEBUFFER, has also been created. This is used to generate the code that calls hc_mtlCreateBuffer, making the code much more readable than before. In summary, this patch lays the groundwork for further improvements to the hashcat core, both on Metal itself and also for other runtimes, particularly OpenCL.
This commit is contained in:
parent
89c0ab9b15
commit
b8c0cfee07
@ -211,6 +211,7 @@
|
||||
- Metal Backend: define USE_BITSELECT and USE_SWIZZLE for Apple Intel
|
||||
- Metal Backend: disable Metal devices only if at least one OpenCL device is active
|
||||
- Metal Backend: improved compute workloads calculation
|
||||
- Metal Backend: improved memory management
|
||||
- Metal Backend: parallelize pipeline state object (PSO) compilation internally
|
||||
- Modules: Added OPTS_TYPE_PT_BASE58 in 28501 28502 28503 28504 28505 28506 30901 30902 30903 30904 30905 30906
|
||||
- Modules: Added module_unstable_warning for 22500, update module_unstable_warning for 10700
|
||||
|
@ -71,11 +71,11 @@ int run_hip_kernel_memset32 (hashcat_ctx_t *hashcat_ctx, hc_devi
|
||||
int run_hip_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, hipDeviceptr_t buf, const u64 size);
|
||||
|
||||
#if defined (__APPLE__)
|
||||
int run_metal_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem buf, const u64 num);
|
||||
int run_metal_kernel_utf8toutf16le (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem buf, const u64 num);
|
||||
int run_metal_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem buf, const u64 offset, const u8 value, const u64 size);
|
||||
int run_metal_kernel_memset32 (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem buf, const u64 offset, const u32 value, const u64 size);
|
||||
int run_metal_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem buf, const u64 size);
|
||||
int run_metal_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t buf, const u64 num);
|
||||
int run_metal_kernel_utf8toutf16le (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t buf, const u64 num);
|
||||
int run_metal_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t buf, const u64 offset, const u8 value, const u64 size);
|
||||
int run_metal_kernel_memset32 (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t buf, const u64 offset, const u32 value, const u64 size);
|
||||
int run_metal_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t buf, const u64 size);
|
||||
#endif
|
||||
|
||||
int run_opencl_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u64 num);
|
||||
|
@ -15,13 +15,127 @@
|
||||
#define mtl_command_queue id
|
||||
#define mtl_function id
|
||||
#define mtl_pipeline id
|
||||
#define mtl_mem id
|
||||
#define mtl_library id
|
||||
#define mtl_command_buffer id
|
||||
#define mtl_command_encoder id
|
||||
#define mtl_blit_command_encoder id
|
||||
#define mtl_compute_command_encoder id
|
||||
|
||||
typedef struct mtl_mem
|
||||
{
|
||||
id buf_ptr;
|
||||
|
||||
unsigned int buf_mode;
|
||||
|
||||
} mtl_mem_t;
|
||||
|
||||
typedef enum metalResourceStorageMode
|
||||
{
|
||||
MTL_STORAGE_MODE_PRIVATE = 0, // only the GPU can access
|
||||
MTL_STORAGE_MODE_SHARED, // both the CPU and the GPU can access
|
||||
MTL_STORAGE_MODE_MANAGED, // double allocations
|
||||
|
||||
} metalResourceStorageMode_t;
|
||||
|
||||
typedef enum metalBufferStorageModeId
|
||||
{
|
||||
metal_d_pws_buf_storageMode,
|
||||
metal_d_pws_amp_buf_storageMode,
|
||||
metal_d_pws_comp_buf_storageMode,
|
||||
metal_d_pws_idx_storageMode,
|
||||
metal_d_rules_storageMode,
|
||||
metal_d_rules_c_storageMode,
|
||||
metal_d_combs_storageMode,
|
||||
metal_d_combs_c_storageMode,
|
||||
metal_d_bfs_storageMode,
|
||||
metal_d_bfs_c_storageMode,
|
||||
metal_d_tm_c_storageMode,
|
||||
metal_d_bitmap_s1_a_storageMode,
|
||||
metal_d_bitmap_s1_b_storageMode,
|
||||
metal_d_bitmap_s1_c_storageMode,
|
||||
metal_d_bitmap_s1_d_storageMode,
|
||||
metal_d_bitmap_s2_a_storageMode,
|
||||
metal_d_bitmap_s2_b_storageMode,
|
||||
metal_d_bitmap_s2_c_storageMode,
|
||||
metal_d_bitmap_s2_d_storageMode,
|
||||
metal_d_plain_bufs_storageMode,
|
||||
metal_d_digests_buf_storageMode,
|
||||
metal_d_digests_shown_storageMode,
|
||||
metal_d_salt_bufs_storageMode,
|
||||
metal_d_esalt_bufs_storageMode,
|
||||
metal_d_tmps_storageMode,
|
||||
metal_d_hooks_storageMode,
|
||||
metal_d_result_storageMode,
|
||||
metal_d_extra0_buf_storageMode,
|
||||
metal_d_extra1_buf_storageMode,
|
||||
metal_d_extra2_buf_storageMode,
|
||||
metal_d_extra3_buf_storageMode,
|
||||
metal_d_root_css_buf_storageMode,
|
||||
metal_d_markov_css_buf_storageMode,
|
||||
metal_d_st_digests_buf_storageMode,
|
||||
metal_d_st_salts_buf_storageMode,
|
||||
metal_d_st_esalts_buf_storageMode,
|
||||
metal_d_kernel_param_storageMode,
|
||||
//
|
||||
metal_private_storageMode,
|
||||
metal_shared_storageMode,
|
||||
metal_managed_storageMode,
|
||||
MTL_BUFFER_CNT
|
||||
|
||||
} metalBufferStorageModeId_t;
|
||||
|
||||
static const metalResourceStorageMode_t metalResourceStorageModes[MTL_BUFFER_CNT] =
|
||||
{
|
||||
[metal_d_pws_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_pws_amp_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_pws_comp_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_pws_idx_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_rules_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_rules_c_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_combs_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_combs_c_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bfs_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bfs_c_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_tm_c_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s1_a_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s1_b_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s1_c_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s1_d_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s2_a_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s2_b_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s2_c_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_bitmap_s2_d_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_plain_bufs_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_digests_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_digests_shown_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_salt_bufs_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_esalt_bufs_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_tmps_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_hooks_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_result_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_extra0_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_extra1_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_extra2_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_extra3_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_root_css_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_markov_css_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_st_digests_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_st_salts_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_st_esalts_buf_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_d_kernel_param_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
//
|
||||
[metal_private_storageMode] = MTL_STORAGE_MODE_PRIVATE,
|
||||
[metal_shared_storageMode] = MTL_STORAGE_MODE_SHARED,
|
||||
[metal_managed_storageMode] = MTL_STORAGE_MODE_MANAGED
|
||||
};
|
||||
|
||||
#define HC_MTL_CREATEBUFFER(ctx, size, ptr, buf_name) \
|
||||
do { \
|
||||
if (hc_mtlCreateBuffer(ctx, device_param->metal_device, size, ptr, \
|
||||
&device_param->metal_d_##buf_name, \
|
||||
metal_d_##buf_name##_storageMode) == -1) return -1; \
|
||||
} while (0)
|
||||
|
||||
typedef enum metalDeviceAttribute
|
||||
{
|
||||
MTL_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 1,
|
||||
@ -84,7 +198,7 @@ int hc_mtlDeviceMaxMemAlloc (void *hashcat_ctx, size_t *bytes, m
|
||||
int hc_mtlMemGetInfo (void *hashcat_ctx, size_t *mem_free, size_t *mem_total);
|
||||
|
||||
int hc_mtlCreateCommandQueue (void *hashcat_ctx, mtl_device_id metal_device, mtl_command_queue *command_queue);
|
||||
int hc_mtlCreateBuffer (void *hashcat_ctx, mtl_device_id metal_device, size_t size, void *ptr, mtl_mem *metal_buffer);
|
||||
int hc_mtlCreateBuffer (void *hashcat_ctx, mtl_device_id metal_device, size_t size, void *ptr, mtl_mem_t *mem, metalBufferStorageModeId_t metal_storage_mode);
|
||||
int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_library metal_library, const char *func_name, mtl_function *metal_function, mtl_pipeline *metal_pipeline);
|
||||
|
||||
int hc_mtlGetMaxTotalThreadsPerThreadgroup (void *hashcat_ctx, mtl_pipeline metal_pipeline, unsigned int *maxTotalThreadsPerThreadgroup);
|
||||
@ -92,13 +206,13 @@ int hc_mtlGetThreadExecutionWidth (void *hashcat_ctx, mtl_pipeline met
|
||||
int hc_mtlGetStaticThreadgroupMemoryLength (void *hashcat_ctx, mtl_pipeline metal_pipeline, unsigned int *staticThreadgroupMemoryLength);
|
||||
|
||||
// copy buffer
|
||||
int hc_mtlMemcpyDtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_mem buf_dst, size_t buf_dst_off, mtl_mem buf_src, size_t buf_src_off, size_t buf_size);
|
||||
int hc_mtlMemcpyDtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_mem_t mem_dst, size_t mem_dst_off, mtl_mem_t mem_src, size_t mem_src_off, size_t buf_size);
|
||||
// write
|
||||
int hc_mtlMemcpyHtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_mem buf_dst, size_t buf_dst_off, const void *buf_src, size_t buf_size);
|
||||
int hc_mtlMemcpyHtoD (void *hashcat_ctx, mtl_device_id metal_device, mtl_command_queue command_queue, mtl_mem_t mem_dst, size_t mem_dst_off, const void *mem_src, size_t buf_size);
|
||||
// read
|
||||
int hc_mtlMemcpyDtoH (void *hashcat_ctx, mtl_command_queue command_queue, void *buf_dst, mtl_mem buf_src, size_t buf_src_off, size_t buf_size);
|
||||
int hc_mtlMemcpyDtoH (void *hashcat_ctx, mtl_device_id metal_device, mtl_command_queue command_queue, void *mem_dst, mtl_mem_t mem_src, size_t mem_src_off, size_t buf_size);
|
||||
|
||||
int hc_mtlReleaseMemObject (void *hashcat_ctx, mtl_mem *metal_buffer);
|
||||
int hc_mtlReleaseMemObject (void *hashcat_ctx, mtl_mem_t *metal_buffer);
|
||||
int hc_mtlReleaseFunction (void *hashcat_ctx, mtl_function *metal_function);
|
||||
int hc_mtlReleaseLibrary (void *hashcat_ctx, mtl_function *metal_library);
|
||||
int hc_mtlReleaseCommandQueue (void *hashcat_ctx, mtl_command_queue command_queue);
|
||||
@ -108,7 +222,7 @@ int hc_mtlCreateLibraryWithSource (void *hashcat_ctx, mtl_device_id me
|
||||
int hc_mtlCreateLibraryWithFile (void *hashcat_ctx, mtl_device_id metal_device, const char *cached_file, mtl_library *metal_library);
|
||||
|
||||
int hc_mtlEncodeComputeCommand_pre (void *hashcat_ctx, mtl_pipeline metal_pipeline, mtl_command_queue metal_command_queue, mtl_command_buffer *metal_command_buffer, mtl_command_encoder *metal_command_encoder);
|
||||
int hc_mtlSetCommandEncoderArg (void *hashcat_ctx, mtl_command_encoder metal_command_encoder, size_t off, size_t idx, mtl_mem buf, void *host_data, size_t host_data_size);
|
||||
int hc_mtlSetCommandEncoderArg (void *hashcat_ctx, mtl_command_encoder metal_command_encoder, size_t off, size_t idx, id buf, void *host_data, size_t host_data_size);
|
||||
|
||||
int hc_mtlEncodeComputeCommand (void *hashcat_ctx, mtl_command_encoder metal_command_encoder, mtl_command_buffer metal_command_buffer, const unsigned int work_dim, const size_t global_work_size[3], const size_t local_work_size[3], double *ms);
|
||||
|
||||
|
@ -1838,43 +1838,43 @@ typedef struct hc_device_param
|
||||
mtl_pipeline metal_pipeline_aux3;
|
||||
mtl_pipeline metal_pipeline_aux4;
|
||||
|
||||
mtl_mem metal_d_pws_buf;
|
||||
mtl_mem metal_d_pws_amp_buf;
|
||||
mtl_mem metal_d_pws_comp_buf;
|
||||
mtl_mem metal_d_pws_idx;
|
||||
mtl_mem metal_d_rules;
|
||||
mtl_mem metal_d_rules_c;
|
||||
mtl_mem metal_d_combs;
|
||||
mtl_mem metal_d_combs_c;
|
||||
mtl_mem metal_d_bfs;
|
||||
mtl_mem metal_d_bfs_c;
|
||||
mtl_mem metal_d_tm_c;
|
||||
mtl_mem metal_d_bitmap_s1_a;
|
||||
mtl_mem metal_d_bitmap_s1_b;
|
||||
mtl_mem metal_d_bitmap_s1_c;
|
||||
mtl_mem metal_d_bitmap_s1_d;
|
||||
mtl_mem metal_d_bitmap_s2_a;
|
||||
mtl_mem metal_d_bitmap_s2_b;
|
||||
mtl_mem metal_d_bitmap_s2_c;
|
||||
mtl_mem metal_d_bitmap_s2_d;
|
||||
mtl_mem metal_d_plain_bufs;
|
||||
mtl_mem metal_d_digests_buf;
|
||||
mtl_mem metal_d_digests_shown;
|
||||
mtl_mem metal_d_salt_bufs;
|
||||
mtl_mem metal_d_esalt_bufs;
|
||||
mtl_mem metal_d_tmps;
|
||||
mtl_mem metal_d_hooks;
|
||||
mtl_mem metal_d_result;
|
||||
mtl_mem metal_d_extra0_buf;
|
||||
mtl_mem metal_d_extra1_buf;
|
||||
mtl_mem metal_d_extra2_buf;
|
||||
mtl_mem metal_d_extra3_buf;
|
||||
mtl_mem metal_d_root_css_buf;
|
||||
mtl_mem metal_d_markov_css_buf;
|
||||
mtl_mem metal_d_st_digests_buf;
|
||||
mtl_mem metal_d_st_salts_buf;
|
||||
mtl_mem metal_d_st_esalts_buf;
|
||||
mtl_mem metal_d_kernel_param;
|
||||
mtl_mem_t metal_d_pws_buf;
|
||||
mtl_mem_t metal_d_pws_amp_buf;
|
||||
mtl_mem_t metal_d_pws_comp_buf;
|
||||
mtl_mem_t metal_d_pws_idx;
|
||||
mtl_mem_t metal_d_rules;
|
||||
mtl_mem_t metal_d_rules_c;
|
||||
mtl_mem_t metal_d_combs;
|
||||
mtl_mem_t metal_d_combs_c;
|
||||
mtl_mem_t metal_d_bfs;
|
||||
mtl_mem_t metal_d_bfs_c;
|
||||
mtl_mem_t metal_d_tm_c;
|
||||
mtl_mem_t metal_d_bitmap_s1_a;
|
||||
mtl_mem_t metal_d_bitmap_s1_b;
|
||||
mtl_mem_t metal_d_bitmap_s1_c;
|
||||
mtl_mem_t metal_d_bitmap_s1_d;
|
||||
mtl_mem_t metal_d_bitmap_s2_a;
|
||||
mtl_mem_t metal_d_bitmap_s2_b;
|
||||
mtl_mem_t metal_d_bitmap_s2_c;
|
||||
mtl_mem_t metal_d_bitmap_s2_d;
|
||||
mtl_mem_t metal_d_plain_bufs;
|
||||
mtl_mem_t metal_d_digests_buf;
|
||||
mtl_mem_t metal_d_digests_shown;
|
||||
mtl_mem_t metal_d_salt_bufs;
|
||||
mtl_mem_t metal_d_esalt_bufs;
|
||||
mtl_mem_t metal_d_tmps;
|
||||
mtl_mem_t metal_d_hooks;
|
||||
mtl_mem_t metal_d_result;
|
||||
mtl_mem_t metal_d_extra0_buf;
|
||||
mtl_mem_t metal_d_extra1_buf;
|
||||
mtl_mem_t metal_d_extra2_buf;
|
||||
mtl_mem_t metal_d_extra3_buf;
|
||||
mtl_mem_t metal_d_root_css_buf;
|
||||
mtl_mem_t metal_d_markov_css_buf;
|
||||
mtl_mem_t metal_d_st_digests_buf;
|
||||
mtl_mem_t metal_d_st_salts_buf;
|
||||
mtl_mem_t metal_d_st_esalts_buf;
|
||||
mtl_mem_t metal_d_kernel_param;
|
||||
|
||||
#endif // __APPLE__
|
||||
|
||||
@ -3276,4 +3276,4 @@ typedef enum hash_category
|
||||
|
||||
typedef aes_ctx AES_KEY;
|
||||
|
||||
#endif // HC_TYPES_H
|
||||
#endif // HC_TYPES_H
|
||||
|
339
src/backend.c
339
src/backend.c
@ -1054,7 +1054,7 @@ int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, c
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, &pw_idx, device_param->metal_d_pws_idx, gidd * sizeof (pw_idx_t), sizeof (pw_idx_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, &pw_idx, device_param->metal_d_pws_idx, gidd * sizeof (pw_idx_t), sizeof (pw_idx_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1087,7 +1087,7 @@ int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, c
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, pw->i, device_param->metal_d_pws_comp_buf, off * sizeof (u32), cnt * sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, pw->i, device_param->metal_d_pws_comp_buf, off * sizeof (u32), cnt * sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1138,7 +1138,7 @@ int copy_pws_idx (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, u
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, dest, device_param->metal_d_pws_idx, gidd * sizeof (pw_idx_t), (cnt * sizeof (pw_idx_t))) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, dest, device_param->metal_d_pws_idx, gidd * sizeof (pw_idx_t), (cnt * sizeof (pw_idx_t))) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1176,7 +1176,7 @@ int copy_pws_comp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, dest, device_param->metal_d_pws_comp_buf, off * sizeof (u32), cnt * sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, dest, device_param->metal_d_pws_comp_buf, off * sizeof (u32), cnt * sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1431,7 +1431,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1486,7 +1486,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1592,7 +1592,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1621,7 +1621,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1683,7 +1683,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1738,7 +1738,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, pws_cnt * hashconfig->hook_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1832,7 +1832,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1861,7 +1861,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, pws_cnt * hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2225,7 +2225,7 @@ int run_hip_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
}
|
||||
|
||||
#if defined (__APPLE__)
|
||||
int run_metal_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, id buf, const u64 num)
|
||||
int run_metal_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t mem, const u64 num)
|
||||
{
|
||||
u64 num_elements = num;
|
||||
|
||||
@ -2243,7 +2243,7 @@ int run_metal_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi
|
||||
|
||||
if (hc_mtlEncodeComputeCommand_pre (hashcat_ctx, device_param->metal_pipeline_atinit, device_param->metal_command_queue, &metal_command_buffer, &metal_command_encoder) == -1) return -1;
|
||||
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 0, buf, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 0, mem.buf_ptr, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 1, NULL, device_param->kernel_params_atinit[1], sizeof (u64)) == -1) return -1;
|
||||
|
||||
double ms = 0;
|
||||
@ -2253,7 +2253,7 @@ int run_metal_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run_metal_kernel_utf8toutf16le (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, id buf, const u64 num)
|
||||
int run_metal_kernel_utf8toutf16le (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t mem, const u64 num)
|
||||
{
|
||||
u64 num_elements = num;
|
||||
|
||||
@ -2271,7 +2271,7 @@ int run_metal_kernel_utf8toutf16le (hashcat_ctx_t *hashcat_ctx, hc_device_param_
|
||||
|
||||
if (hc_mtlEncodeComputeCommand_pre (hashcat_ctx, device_param->metal_pipeline_utf8toutf16le, device_param->metal_command_queue, &metal_command_buffer, &metal_command_encoder) == -1) return -1;
|
||||
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 0, buf, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 0, mem.buf_ptr, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 1, NULL, device_param->kernel_params_utf8toutf16le[1], sizeof (u64)) == -1) return -1;
|
||||
|
||||
double ms = 0;
|
||||
@ -2281,7 +2281,7 @@ int run_metal_kernel_utf8toutf16le (hashcat_ctx_t *hashcat_ctx, hc_device_param_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run_metal_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, id buf, const u64 size)
|
||||
int run_metal_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t mem, const u64 size)
|
||||
{
|
||||
const u64 num16d = size / 16;
|
||||
const u64 num16m = size % 16;
|
||||
@ -2299,7 +2299,7 @@ int run_metal_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devic
|
||||
|
||||
if (hc_mtlEncodeComputeCommand_pre (hashcat_ctx, device_param->metal_pipeline_bzero, device_param->metal_command_queue, &metal_command_buffer, &metal_command_encoder) == -1) return -1;
|
||||
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 0, buf, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 0, mem.buf_ptr, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, 1, NULL, (void *) &num16d, sizeof (u64)) == -1) return -1;
|
||||
|
||||
const size_t global_work_size[3] = { num_elements, 1, 1 };
|
||||
@ -2318,20 +2318,20 @@ int run_metal_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devic
|
||||
{
|
||||
u8 *bzeros_apple = (u8 *) hccalloc (num16m, sizeof (u8));
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, buf, num16d * 16, bzeros_apple, num16m) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, mem, num16d * 16, bzeros_apple, num16m) == -1) return -1;
|
||||
|
||||
hcfree (bzeros_apple);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, buf, num16d * 16, bzeros, num16m) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, mem, num16d * 16, bzeros, num16m) == -1) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run_metal_kernel_memset32 (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem buf, const u64 offset, const u32 value, const u64 size)
|
||||
int run_metal_kernel_memset32 (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, mtl_mem_t mem, const u64 offset, const u32 value, const u64 size)
|
||||
{
|
||||
int rc;
|
||||
|
||||
@ -2350,7 +2350,7 @@ int run_metal_kernel_memset32 (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *de
|
||||
tmp[i] = value;
|
||||
}
|
||||
|
||||
rc = hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, buf, offset, tmp, size);
|
||||
rc = hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, mem, offset, tmp, size);
|
||||
|
||||
hcfree (tmp);
|
||||
|
||||
@ -2878,13 +2878,14 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con
|
||||
case KERN_RUN_AUX4: metal_pipeline = device_param->metal_pipeline_aux4; break;
|
||||
}
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_kernel_param, 0, &device_param->kernel_param, device_param->size_kernel_params) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_kernel_param, 0, &device_param->kernel_param, device_param->size_kernel_params) == -1) return -1;
|
||||
|
||||
if (hc_mtlEncodeComputeCommand_pre (hashcat_ctx, metal_pipeline, device_param->metal_command_queue, &metal_command_buffer, &metal_command_encoder) == -1) return -1;
|
||||
|
||||
mtl_mem metal_buffer = NULL;
|
||||
mtl_mem_t mem;
|
||||
mem.buf_ptr = NULL;
|
||||
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, sizeof (u8), NULL, &metal_buffer) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, sizeof (u8), NULL, &mem, metal_private_storageMode) == -1) return -1;
|
||||
|
||||
// all buffers must be allocated
|
||||
for (u32 i = 0; i <= 24; i++)
|
||||
@ -2892,7 +2893,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con
|
||||
// allocate fake buffer if NULL
|
||||
if (device_param->kernel_params[i] == NULL)
|
||||
{
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, i, metal_buffer, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, i, mem.buf_ptr, NULL, 0) == -1) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2989,7 +2990,7 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con
|
||||
// allocate fake buffer if NULL
|
||||
if (device_param->kernel_params[i] == NULL)
|
||||
{
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, i, metal_buffer, NULL, 0) == -1) return -1;
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, i, mem.buf_ptr, NULL, 0) == -1) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3542,16 +3543,18 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
// all buffers must be allocated
|
||||
int tmp_buf_cnt = 0;
|
||||
|
||||
mtl_mem tmp_buf[5] = { 0 };
|
||||
mtl_mem_t tmp_buf[5];
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
// allocate fake buffer if NULL
|
||||
if (device_param->kernel_params_amp[i] == NULL)
|
||||
{
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, sizeof (u8), NULL, &tmp_buf[tmp_buf_cnt]) == -1) return -1;
|
||||
tmp_buf[tmp_buf_cnt].buf_ptr = NULL;
|
||||
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, i, tmp_buf[tmp_buf_cnt], NULL, 0) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, sizeof (u8), NULL, &tmp_buf[tmp_buf_cnt], metal_private_storageMode) == -1) return -1;
|
||||
|
||||
if (hc_mtlSetCommandEncoderArg (hashcat_ctx, metal_command_encoder, 0, i, tmp_buf[tmp_buf_cnt].buf_ptr, NULL, 0) == -1) return -1;
|
||||
|
||||
tmp_buf_cnt++;
|
||||
}
|
||||
@ -3574,7 +3577,7 @@ int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
{
|
||||
hc_mtlReleaseMemObject (hashcat_ctx, &tmp_buf[i]);
|
||||
|
||||
tmp_buf[i] = NULL;
|
||||
tmp_buf[i].buf_ptr = NULL;
|
||||
}
|
||||
|
||||
if (rc_cc == -1) return -1;
|
||||
@ -3721,7 +3724,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
|
||||
const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt;
|
||||
|
||||
@ -3729,7 +3732,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
|
||||
if (off)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -3785,7 +3788,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
|
||||
const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt;
|
||||
|
||||
@ -3793,7 +3796,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
|
||||
if (off)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -3883,7 +3886,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
|
||||
const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt;
|
||||
|
||||
@ -3891,7 +3894,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
|
||||
if (off)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -3947,7 +3950,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
|
||||
const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt;
|
||||
|
||||
@ -3955,7 +3958,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
|
||||
if (off)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -4009,7 +4012,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_idx, 0, device_param->pws_idx, pws_cnt * sizeof (pw_idx_t)) == -1) return -1;
|
||||
|
||||
const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt;
|
||||
|
||||
@ -4017,7 +4020,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
|
||||
|
||||
if (off)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_comp_buf, 0, device_param->pws_comp, off * sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -4409,7 +4412,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_combs_c, 0, device_param->combs_buf, innerloop_left * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_combs_c, 0, device_param->combs_buf, innerloop_left * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -4602,7 +4605,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_combs_c, 0, device_param->combs_buf, innerloop_left * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_combs_c, 0, device_param->combs_buf, innerloop_left * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -8664,7 +8667,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
{
|
||||
// following the same logic as for OpenCL, explained later
|
||||
|
||||
mtl_mem *tmp_device = (mtl_mem *) hccalloc (MAX_ALLOC_CHECKS_CNT, sizeof (mtl_mem));
|
||||
mtl_mem_t *tmp_device = (mtl_mem_t *) hccalloc (MAX_ALLOC_CHECKS_CNT, sizeof (mtl_mem_t));
|
||||
|
||||
u64 c;
|
||||
|
||||
@ -8672,7 +8675,8 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
{
|
||||
if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= device_param->device_global_mem) break;
|
||||
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, MAX_ALLOC_CHECKS_SIZE, NULL, &tmp_device[c]) == -1)
|
||||
// using SHARED by default here, no performance requirements
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, MAX_ALLOC_CHECKS_SIZE, NULL, &tmp_device[c], metal_shared_storageMode) == -1)
|
||||
{
|
||||
c--;
|
||||
|
||||
@ -8683,11 +8687,11 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
|
||||
u8 tmp_host[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, tmp_device[c], 0, tmp_host, sizeof (tmp_host)) == -1) break;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, tmp_host, tmp_device[c], 0, sizeof (tmp_host)) == -1) break;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, tmp_device[c], 0, tmp_host, sizeof (tmp_host)) == -1) break;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, tmp_host, tmp_device[c], 0, sizeof (tmp_host)) == -1) break;
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, tmp_device[c], MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), tmp_host, sizeof (tmp_host)) == -1) break;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, tmp_host, tmp_device[c], MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host)) == -1) break;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, tmp_device[c], MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), tmp_host, sizeof (tmp_host)) == -1) break;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, tmp_host, tmp_device[c], MAX_ALLOC_CHECKS_SIZE - sizeof (tmp_host), sizeof (tmp_host)) == -1) break;
|
||||
}
|
||||
|
||||
device_param->device_available_mem = MAX_ALLOC_CHECKS_SIZE;
|
||||
@ -8703,7 +8707,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
{
|
||||
if (((c + 1 + 1) * MAX_ALLOC_CHECKS_SIZE) >= device_param->device_global_mem) break;
|
||||
|
||||
if (tmp_device[c] != NULL)
|
||||
if (tmp_device[c].buf_ptr != NULL)
|
||||
{
|
||||
if (hc_mtlReleaseMemObject (hashcat_ctx, &tmp_device[c]) == -1) return -1;
|
||||
}
|
||||
@ -12194,50 +12198,37 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s1_a) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s1_b) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s1_c) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s1_d) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s2_a) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s2_b) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s2_c) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, bitmap_ctx->bitmap_size, NULL, &device_param->metal_d_bitmap_s2_d) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s1_a);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s1_b);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s1_c);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s1_d);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s2_a);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s2_b);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s2_c);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, bitmap_ctx->bitmap_size, NULL, bitmap_s2_d);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_plains, NULL, plain_bufs);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_digests, NULL, digests_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_shown, NULL, digests_shown);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_salts, NULL, salt_bufs);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_results, NULL, result);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_extra_buffer1, NULL, extra0_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_extra_buffer2, NULL, extra1_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_extra_buffer3, NULL, extra2_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_extra_buffer4, NULL, extra3_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_st_digests, NULL, st_digests_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_st_salts, NULL, st_salts_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_kernel_params, NULL, kernel_param);
|
||||
|
||||
// shared
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_plains, NULL, &device_param->metal_d_plain_bufs) == -1) return -1;
|
||||
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_digests, NULL, &device_param->metal_d_digests_buf) == -1) return -1;
|
||||
|
||||
// shared
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_shown, NULL, &device_param->metal_d_digests_shown) == -1) return -1;
|
||||
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_salts, NULL, &device_param->metal_d_salt_bufs) == -1) return -1;
|
||||
|
||||
// shared
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_results, NULL, &device_param->metal_d_result) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_extra_buffer1, NULL, &device_param->metal_d_extra0_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_extra_buffer2, NULL, &device_param->metal_d_extra1_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_extra_buffer3, NULL, &device_param->metal_d_extra2_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_extra_buffer4, NULL, &device_param->metal_d_extra3_buf) == -1) return -1;
|
||||
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_st_digests, NULL, &device_param->metal_d_st_digests_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_st_salts, NULL, &device_param->metal_d_st_salts_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_kernel_params, NULL, &device_param->metal_d_kernel_param) == -1) return -1;
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_a, 0, bitmap_ctx->bitmap_s1_a, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_b, 0, bitmap_ctx->bitmap_s1_b, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_c, 0, bitmap_ctx->bitmap_s1_c, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_d, 0, bitmap_ctx->bitmap_s1_d, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_a, 0, bitmap_ctx->bitmap_s2_a, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_b, 0, bitmap_ctx->bitmap_s2_b, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_c, 0, bitmap_ctx->bitmap_s2_c, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_d, 0, bitmap_ctx->bitmap_s2_d, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_digests_buf, 0, hashes->digests_buf, size_digests) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_salt_bufs, 0, hashes->salts_buf, size_salts) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_a, 0, bitmap_ctx->bitmap_s1_a, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_b, 0, bitmap_ctx->bitmap_s1_b, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_c, 0, bitmap_ctx->bitmap_s1_c, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s1_d, 0, bitmap_ctx->bitmap_s1_d, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_a, 0, bitmap_ctx->bitmap_s2_a, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_b, 0, bitmap_ctx->bitmap_s2_b, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_c, 0, bitmap_ctx->bitmap_s2_c, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bitmap_s2_d, 0, bitmap_ctx->bitmap_s2_d, bitmap_ctx->bitmap_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_digests_buf, 0, hashes->digests_buf, size_digests) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_salt_bufs, 0, hashes->salts_buf, size_salts) == -1) return -1;
|
||||
|
||||
/**
|
||||
* special buffers
|
||||
@ -12245,57 +12236,51 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (user_options->slow_candidates == true)
|
||||
{
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_rules_c, NULL, &device_param->metal_d_rules_c) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_rules_c, NULL, rules_c);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
|
||||
{
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_rules, NULL, &device_param->metal_d_rules) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_rules_c, NULL, &device_param->metal_d_rules_c) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_rules, NULL, rules);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_rules_c, NULL, rules_c);
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_rules, 0, straight_ctx->kernel_rules_buf, size_rules_src) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_rules, 0, straight_ctx->kernel_rules_buf, size_rules_src) == -1) return -1;
|
||||
}
|
||||
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
|
||||
{
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_combs, NULL, &device_param->metal_d_combs) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_combs, NULL, &device_param->metal_d_combs_c) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_root_css, NULL, &device_param->metal_d_root_css_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_markov_css, NULL, &device_param->metal_d_markov_css_buf) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_combs, NULL, combs);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_combs, NULL, combs_c);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_root_css, NULL, root_css_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_markov_css, NULL, markov_css_buf);
|
||||
}
|
||||
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
|
||||
{
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_bfs, NULL, &device_param->metal_d_bfs) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_bfs, NULL, &device_param->metal_d_bfs_c) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_tm, NULL, &device_param->metal_d_tm_c) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_root_css, NULL, &device_param->metal_d_root_css_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_markov_css, NULL, &device_param->metal_d_markov_css_buf) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_bfs, NULL, bfs);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_bfs, NULL, bfs_c);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_tm, NULL, tm_c);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_root_css, NULL, root_css_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_markov_css, NULL, markov_css_buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (size_esalts)
|
||||
{
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_esalts, NULL, &device_param->metal_d_esalt_bufs) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_esalts, NULL, esalt_bufs);
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_esalt_bufs, 0, hashes->esalts_buf, size_esalts) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_esalt_bufs, 0, hashes->esalts_buf, size_esalts) == -1) return -1;
|
||||
}
|
||||
|
||||
if (hashconfig->st_hash != NULL)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_st_digests_buf, 0, hashes->st_digests_buf, size_st_digests) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_st_salts_buf, 0, hashes->st_salts_buf, size_st_salts) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_st_digests_buf, 0, hashes->st_digests_buf, size_st_digests) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_st_salts_buf, 0, hashes->st_salts_buf, size_st_salts) == -1) return -1;
|
||||
|
||||
if (size_esalts)
|
||||
{
|
||||
// gpu only
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_st_esalts, NULL, &device_param->metal_d_st_esalts_buf) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_st_esalts, NULL, st_esalts_buf);
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_st_esalts_buf, 0, hashes->st_esalts_buf, size_st_esalts) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_st_esalts_buf, 0, hashes->st_esalts_buf, size_st_esalts) == -1) return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12474,30 +12459,30 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params[ 0] = NULL; // device_param->metal_d_pws_buf;
|
||||
device_param->kernel_params[ 1] = device_param->metal_d_rules_c;
|
||||
device_param->kernel_params[ 2] = device_param->metal_d_combs_c;
|
||||
device_param->kernel_params[ 3] = device_param->metal_d_bfs_c;
|
||||
device_param->kernel_params[ 1] = device_param->metal_d_rules_c.buf_ptr;
|
||||
device_param->kernel_params[ 2] = device_param->metal_d_combs_c.buf_ptr;
|
||||
device_param->kernel_params[ 3] = device_param->metal_d_bfs_c.buf_ptr;
|
||||
device_param->kernel_params[ 4] = NULL; // device_param->metal_d_tmps;
|
||||
device_param->kernel_params[ 5] = NULL; // device_param->metal_d_hooks;
|
||||
device_param->kernel_params[ 6] = device_param->metal_d_bitmap_s1_a;
|
||||
device_param->kernel_params[ 7] = device_param->metal_d_bitmap_s1_b;
|
||||
device_param->kernel_params[ 8] = device_param->metal_d_bitmap_s1_c;
|
||||
device_param->kernel_params[ 9] = device_param->metal_d_bitmap_s1_d;
|
||||
device_param->kernel_params[10] = device_param->metal_d_bitmap_s2_a;
|
||||
device_param->kernel_params[11] = device_param->metal_d_bitmap_s2_b;
|
||||
device_param->kernel_params[12] = device_param->metal_d_bitmap_s2_c;
|
||||
device_param->kernel_params[13] = device_param->metal_d_bitmap_s2_d;
|
||||
device_param->kernel_params[14] = device_param->metal_d_plain_bufs;
|
||||
device_param->kernel_params[15] = device_param->metal_d_digests_buf;
|
||||
device_param->kernel_params[16] = device_param->metal_d_digests_shown;
|
||||
device_param->kernel_params[17] = device_param->metal_d_salt_bufs;
|
||||
device_param->kernel_params[18] = device_param->metal_d_esalt_bufs;
|
||||
device_param->kernel_params[19] = device_param->metal_d_result;
|
||||
device_param->kernel_params[20] = device_param->metal_d_extra0_buf;
|
||||
device_param->kernel_params[21] = device_param->metal_d_extra1_buf;
|
||||
device_param->kernel_params[22] = device_param->metal_d_extra2_buf;
|
||||
device_param->kernel_params[23] = device_param->metal_d_extra3_buf;
|
||||
device_param->kernel_params[24] = device_param->metal_d_kernel_param;
|
||||
device_param->kernel_params[ 6] = device_param->metal_d_bitmap_s1_a.buf_ptr;
|
||||
device_param->kernel_params[ 7] = device_param->metal_d_bitmap_s1_b.buf_ptr;
|
||||
device_param->kernel_params[ 8] = device_param->metal_d_bitmap_s1_c.buf_ptr;
|
||||
device_param->kernel_params[ 9] = device_param->metal_d_bitmap_s1_d.buf_ptr;
|
||||
device_param->kernel_params[10] = device_param->metal_d_bitmap_s2_a.buf_ptr;
|
||||
device_param->kernel_params[11] = device_param->metal_d_bitmap_s2_b.buf_ptr;
|
||||
device_param->kernel_params[12] = device_param->metal_d_bitmap_s2_c.buf_ptr;
|
||||
device_param->kernel_params[13] = device_param->metal_d_bitmap_s2_d.buf_ptr;
|
||||
device_param->kernel_params[14] = device_param->metal_d_plain_bufs.buf_ptr;
|
||||
device_param->kernel_params[15] = device_param->metal_d_digests_buf.buf_ptr;
|
||||
device_param->kernel_params[16] = device_param->metal_d_digests_shown.buf_ptr;
|
||||
device_param->kernel_params[17] = device_param->metal_d_salt_bufs.buf_ptr;
|
||||
device_param->kernel_params[18] = device_param->metal_d_esalt_bufs.buf_ptr;
|
||||
device_param->kernel_params[19] = device_param->metal_d_result.buf_ptr;
|
||||
device_param->kernel_params[20] = device_param->metal_d_extra0_buf.buf_ptr;
|
||||
device_param->kernel_params[21] = device_param->metal_d_extra1_buf.buf_ptr;
|
||||
device_param->kernel_params[22] = device_param->metal_d_extra2_buf.buf_ptr;
|
||||
device_param->kernel_params[23] = device_param->metal_d_extra3_buf.buf_ptr;
|
||||
device_param->kernel_params[24] = device_param->metal_d_kernel_param.buf_ptr;
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
||||
@ -12557,7 +12542,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_mp[0] = device_param->metal_d_combs;
|
||||
device_param->kernel_params_mp[0] = device_param->metal_d_combs.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12583,7 +12568,7 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_mp[0] = device_param->metal_d_combs;
|
||||
device_param->kernel_params_mp[0] = device_param->metal_d_combs.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12615,8 +12600,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_mp[1] = device_param->metal_d_root_css_buf;
|
||||
device_param->kernel_params_mp[2] = device_param->metal_d_markov_css_buf;
|
||||
device_param->kernel_params_mp[1] = device_param->metal_d_root_css_buf.buf_ptr;
|
||||
device_param->kernel_params_mp[2] = device_param->metal_d_markov_css_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12660,8 +12645,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_mp_l[1] = device_param->metal_d_root_css_buf;
|
||||
device_param->kernel_params_mp_l[2] = device_param->metal_d_markov_css_buf;
|
||||
device_param->kernel_params_mp_l[1] = device_param->metal_d_root_css_buf.buf_ptr;
|
||||
device_param->kernel_params_mp_l[2] = device_param->metal_d_markov_css_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12703,9 +12688,9 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_mp_r[0] = device_param->metal_d_bfs;
|
||||
device_param->kernel_params_mp_r[1] = device_param->metal_d_root_css_buf;
|
||||
device_param->kernel_params_mp_r[2] = device_param->metal_d_markov_css_buf;
|
||||
device_param->kernel_params_mp_r[0] = device_param->metal_d_bfs.buf_ptr;
|
||||
device_param->kernel_params_mp_r[1] = device_param->metal_d_root_css_buf.buf_ptr;
|
||||
device_param->kernel_params_mp_r[2] = device_param->metal_d_markov_css_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12749,9 +12734,9 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
device_param->kernel_params_amp[0] = NULL; // device_param->metal_d_pws_buf;
|
||||
device_param->kernel_params_amp[1] = NULL; // device_param->metal_d_pws_amp_buf;
|
||||
device_param->kernel_params_amp[2] = device_param->metal_d_rules_c;
|
||||
device_param->kernel_params_amp[3] = device_param->metal_d_combs_c;
|
||||
device_param->kernel_params_amp[4] = device_param->metal_d_bfs_c;
|
||||
device_param->kernel_params_amp[2] = device_param->metal_d_rules_c.buf_ptr;
|
||||
device_param->kernel_params_amp[3] = device_param->metal_d_combs_c.buf_ptr;
|
||||
device_param->kernel_params_amp[4] = device_param->metal_d_bfs_c.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -12782,8 +12767,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_tm[0] = device_param->metal_d_bfs_c;
|
||||
device_param->kernel_params_tm[1] = device_param->metal_d_tm_c;
|
||||
device_param->kernel_params_tm[0] = device_param->metal_d_bfs_c.buf_ptr;
|
||||
device_param->kernel_params_tm[1] = device_param->metal_d_tm_c.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -16625,12 +16610,12 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_pws, NULL, &device_param->metal_d_pws_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_pws_amp, NULL, &device_param->metal_d_pws_amp_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_pws_comp, NULL, &device_param->metal_d_pws_comp_buf) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_pws_idx, NULL, &device_param->metal_d_pws_idx) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_tmps, NULL, &device_param->metal_d_tmps) == -1) return -1;
|
||||
if (hc_mtlCreateBuffer (hashcat_ctx, device_param->metal_device, size_hooks, NULL, &device_param->metal_d_hooks) == -1) return -1;
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_pws, NULL, pws_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_pws_amp, NULL, pws_amp_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_pws_comp, NULL, pws_comp_buf);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_pws_idx, NULL, pws_idx);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_tmps, NULL, tmps);
|
||||
HC_MTL_CREATEBUFFER(hashcat_ctx, size_hooks, NULL, hooks);
|
||||
|
||||
if (run_metal_kernel_bzero (hashcat_ctx, device_param, device_param->metal_d_pws_buf, device_param->size_pws) == -1) return -1;
|
||||
if (run_metal_kernel_bzero (hashcat_ctx, device_param, device_param->metal_d_pws_amp_buf, device_param->size_pws_amp) == -1) return -1;
|
||||
@ -16728,9 +16713,9 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params[ 0] = device_param->metal_d_pws_buf;
|
||||
device_param->kernel_params[ 4] = device_param->metal_d_tmps;
|
||||
device_param->kernel_params[ 5] = device_param->metal_d_hooks;
|
||||
device_param->kernel_params[ 0] = device_param->metal_d_pws_buf.buf_ptr;
|
||||
device_param->kernel_params[ 4] = device_param->metal_d_tmps.buf_ptr;
|
||||
device_param->kernel_params[ 5] = device_param->metal_d_hooks.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -16776,8 +16761,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_mp[0] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
||||
? device_param->metal_d_pws_buf
|
||||
: device_param->metal_d_pws_amp_buf;
|
||||
? device_param->metal_d_pws_buf.buf_ptr
|
||||
: device_param->metal_d_pws_amp_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -16816,8 +16801,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_mp_l[0] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
||||
? device_param->metal_d_pws_buf
|
||||
: device_param->metal_d_pws_amp_buf;
|
||||
? device_param->metal_d_pws_buf.buf_ptr
|
||||
: device_param->metal_d_pws_amp_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -16858,8 +16843,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_amp[0] = device_param->metal_d_pws_buf;
|
||||
device_param->kernel_params_amp[1] = device_param->metal_d_pws_amp_buf;
|
||||
device_param->kernel_params_amp[0] = device_param->metal_d_pws_buf.buf_ptr;
|
||||
device_param->kernel_params_amp[1] = device_param->metal_d_pws_amp_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -16903,11 +16888,11 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params_decompress[0] = device_param->metal_d_pws_idx;
|
||||
device_param->kernel_params_decompress[1] = device_param->metal_d_pws_comp_buf;
|
||||
device_param->kernel_params_decompress[0] = device_param->metal_d_pws_idx.buf_ptr;
|
||||
device_param->kernel_params_decompress[1] = device_param->metal_d_pws_comp_buf.buf_ptr;
|
||||
device_param->kernel_params_decompress[2] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
||||
? device_param->metal_d_pws_buf
|
||||
: device_param->metal_d_pws_amp_buf;
|
||||
? device_param->metal_d_pws_buf.buf_ptr
|
||||
: device_param->metal_d_pws_amp_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -17476,8 +17461,8 @@ int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_root_css_buf, 0, mask_ctx->root_css_buf, device_param->size_root_css) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_markov_css_buf, 0, mask_ctx->markov_css_buf, device_param->size_markov_css) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_root_css_buf, 0, mask_ctx->root_css_buf, device_param->size_root_css) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_markov_css_buf, 0, mask_ctx->markov_css_buf, device_param->size_markov_css) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -17532,8 +17517,8 @@ int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_root_css_buf, 0, mask_ctx->root_css_buf, device_param->size_root_css) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_markov_css_buf, 0, mask_ctx->markov_css_buf, device_param->size_markov_css) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_root_css_buf, 0, mask_ctx->root_css_buf, device_param->size_root_css) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_markov_css_buf, 0, mask_ctx->markov_css_buf, device_param->size_markov_css) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
409
src/ext_metal.m
409
src/ext_metal.m
@ -54,7 +54,7 @@ static bool iokit_getGPUCore (void *hashcat_ctx, int *gpu_core)
|
||||
|
||||
int gc = 0;
|
||||
|
||||
if (num == nil || CFNumberGetValue (num, kCFNumberIntType, &gc) == false)
|
||||
if (num == NULL || CFNumberGetValue (num, kCFNumberIntType, &gc) == false)
|
||||
{
|
||||
//event_log_error (hashcat_ctx, "IORegistryEntryCreateCFProperty(): 'gpu-core-count' entry not found");
|
||||
}
|
||||
@ -98,7 +98,7 @@ static int hc_mtlInvocationHelper (id target, SEL selector, void *returnValue)
|
||||
|
||||
static int hc_mtlBuildOptionsToDict (void *hashcat_ctx, const char *build_options_buf, const char *include_path, NSMutableDictionary *build_options_dict)
|
||||
{
|
||||
if (build_options_buf == nil)
|
||||
if (build_options_buf == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): build_options_buf is NULL", __func__);
|
||||
|
||||
@ -174,7 +174,7 @@ static int hc_mtlBuildOptionsToDict (void *hashcat_ctx, const char *build_option
|
||||
#ifdef DEBUG
|
||||
const char *tmp = [key UTF8String];
|
||||
|
||||
if (tmp != nil && strlen (tmp) > 0)
|
||||
if (tmp != NULL && strlen (tmp) > 0)
|
||||
{
|
||||
event_log_warning (hashcat_ctx, "%s(): skipping malformed build option: '%s'", __func__, tmp);
|
||||
}
|
||||
@ -188,12 +188,12 @@ static int hc_mtlBuildOptionsToDict (void *hashcat_ctx, const char *build_option
|
||||
value = [components[1] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
||||
}
|
||||
|
||||
[build_options_dict setObject:value forKey:key];
|
||||
[build_options_dict setObject: value forKey: key];
|
||||
}
|
||||
|
||||
// if set, add INCLUDE_PATH to hack Apple kernel build from source limitation on -I usage
|
||||
|
||||
if (include_path != nil)
|
||||
if (include_path != NULL)
|
||||
{
|
||||
NSString *path_key = @"INCLUDE_PATH";
|
||||
NSString *path_value = [NSString stringWithCString: include_path encoding: NSUTF8StringEncoding];
|
||||
@ -202,7 +202,7 @@ static int hc_mtlBuildOptionsToDict (void *hashcat_ctx, const char *build_option
|
||||
|
||||
path_value = [path_value stringByReplacingOccurrencesOfString:@" " withString:@"\\ "];
|
||||
|
||||
[build_options_dict setObject:path_value forKey:path_key];
|
||||
[build_options_dict setObject: path_value forKey: path_key];
|
||||
}
|
||||
|
||||
//NSLog(@"Dict:\n%@", build_options_dict);
|
||||
@ -271,10 +271,12 @@ int hc_mtlDeviceGetCount (void *hashcat_ctx, int *count)
|
||||
|
||||
CFArrayRef devices = (CFArrayRef) MTLCopyAllDevices ();
|
||||
|
||||
if (devices == nil)
|
||||
if (devices == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "metalDeviceGetCount(): empty device objects");
|
||||
|
||||
mtl->devices = nil;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -302,7 +304,7 @@ int hc_mtlDeviceGet (void *hashcat_ctx, mtl_device_id *metal_device, int ordinal
|
||||
|
||||
mtl_device_id device = (mtl_device_id) CFArrayGetValueAtIndex (mtl->devices, ordinal);
|
||||
|
||||
if (device == nil)
|
||||
if (device == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "metalDeviceGet(): invalid index");
|
||||
|
||||
@ -354,7 +356,7 @@ int hc_mtlDeviceGetName (void *hashcat_ctx, char *name, size_t len, mtl_device_i
|
||||
|
||||
const char *device_name_str = [device_name_ptr UTF8String];
|
||||
|
||||
if (device_name_str == nil)
|
||||
if (device_name_str == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get UTF8String from device name", __func__);
|
||||
|
||||
@ -522,7 +524,9 @@ int hc_mtlMemGetInfo (void *hashcat_ctx, size_t *mem_free, size_t *mem_total)
|
||||
if (mtl == NULL) return -1;
|
||||
|
||||
struct vm_statistics64 vm_stats;
|
||||
|
||||
vm_size_t page_size = 0;
|
||||
|
||||
unsigned int count = HOST_VM_INFO64_COUNT;
|
||||
|
||||
mach_port_t port = mach_host_self ();
|
||||
@ -542,9 +546,11 @@ int hc_mtlMemGetInfo (void *hashcat_ctx, size_t *mem_free, size_t *mem_total)
|
||||
}
|
||||
|
||||
uint64_t mem_free_tmp = (uint64_t) (vm_stats.free_count - vm_stats.speculative_count) * page_size;
|
||||
|
||||
uint64_t mem_used_tmp = (uint64_t) (vm_stats.active_count + vm_stats.inactive_count + vm_stats.wire_count) * page_size;
|
||||
|
||||
*mem_free = (size_t) mem_free_tmp;
|
||||
*mem_free = (size_t) (mem_free_tmp);
|
||||
|
||||
*mem_total = (size_t) (mem_free_tmp + mem_used_tmp);
|
||||
|
||||
return 0;
|
||||
@ -681,7 +687,7 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (func_name == nil)
|
||||
if (func_name == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): invalid function name", __func__);
|
||||
|
||||
@ -827,7 +833,7 @@ int hc_mtlGetStaticThreadgroupMemoryLength (void *hashcat_ctx, mtl_pipeline meta
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hc_mtlCreateBuffer (void *hashcat_ctx, mtl_device_id metal_device, size_t size, void *ptr, mtl_mem *metal_buffer)
|
||||
int hc_mtlCreateBuffer (void *hashcat_ctx, mtl_device_id metal_device, size_t size, void *ptr, mtl_mem_t *mem, metalBufferStorageModeId_t metal_storage_mode)
|
||||
{
|
||||
backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx;
|
||||
|
||||
@ -842,32 +848,95 @@ int hc_mtlCreateBuffer (void *hashcat_ctx, mtl_device_id metal_device, size_t si
|
||||
return -1;
|
||||
}
|
||||
|
||||
mtl_mem buf = NULL;
|
||||
// MTLResourceOptions bufferOptions = MTLResourceStorageModeShared;
|
||||
|
||||
MTLResourceOptions bufferOptions = MTLResourceStorageModeShared;
|
||||
MTLResourceOptions bufferOptions;
|
||||
|
||||
if (ptr == NULL)
|
||||
metalResourceStorageMode_t storageMode = metalResourceStorageModes[metal_storage_mode];
|
||||
|
||||
switch (storageMode)
|
||||
{
|
||||
buf = [metal_device newBufferWithLength:size options:bufferOptions];
|
||||
case MTL_STORAGE_MODE_PRIVATE:
|
||||
bufferOptions = MTLResourceStorageModePrivate;
|
||||
break;
|
||||
|
||||
case MTL_STORAGE_MODE_SHARED:
|
||||
bufferOptions = MTLResourceStorageModeShared;
|
||||
break;
|
||||
|
||||
case MTL_STORAGE_MODE_MANAGED:
|
||||
bufferOptions = MTLResourceStorageModeManaged;
|
||||
break;
|
||||
|
||||
default:
|
||||
event_log_error (hashcat_ctx, "%s(): invalid metal storage mode argument", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
NSString *deviceName = [metal_device name];
|
||||
|
||||
if ([deviceName containsString:@"AMD"])
|
||||
{
|
||||
if (bufferOptions == MTLResourceStorageModeShared)
|
||||
{
|
||||
// AMD discrete GPU perform best on MANAGED
|
||||
bufferOptions = MTLResourceStorageModeManaged;
|
||||
}
|
||||
}
|
||||
else if ([deviceName containsString:@"Intel"])
|
||||
{
|
||||
if (bufferOptions == MTLResourceStorageModeShared)
|
||||
{
|
||||
// for Intel integrated GPU we need more testing with stable HW
|
||||
// bufferOptions = MTLResourceStorageModeManaged;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = [metal_device newBufferWithBytes:ptr length:size options:bufferOptions];
|
||||
// we are on Apple Silicon, nothing to do ;)
|
||||
}
|
||||
|
||||
if (buf == nil)
|
||||
if (ptr == NULL)
|
||||
{
|
||||
mem->buf_ptr = [metal_device newBufferWithLength: size options: bufferOptions];
|
||||
}
|
||||
else
|
||||
{
|
||||
mem->buf_ptr = [metal_device newBufferWithBytes: ptr length: size options: bufferOptions];
|
||||
}
|
||||
|
||||
if (mem->buf_ptr == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): %s failed (size: %zu)", __func__, (ptr == NULL) ? "newBufferWithLength" : "newBufferWithBytes", size);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
*metal_buffer = buf;
|
||||
// now set buf_mode
|
||||
|
||||
switch (bufferOptions)
|
||||
{
|
||||
case MTLResourceStorageModePrivate:
|
||||
mem->buf_mode = MTL_STORAGE_MODE_PRIVATE;
|
||||
break;
|
||||
|
||||
case MTLResourceStorageModeShared:
|
||||
mem->buf_mode = MTL_STORAGE_MODE_SHARED;
|
||||
break;
|
||||
|
||||
case MTLResourceStorageModeManaged:
|
||||
mem->buf_mode = MTL_STORAGE_MODE_MANAGED;
|
||||
break;
|
||||
|
||||
default:
|
||||
event_log_error (hashcat_ctx, "%s(): invalid metal storage mode argument", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hc_mtlReleaseMemObject (void *hashcat_ctx, mtl_mem *metal_buffer)
|
||||
int hc_mtlReleaseMemObject (void *hashcat_ctx, mtl_mem_t *mem)
|
||||
{
|
||||
backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx;
|
||||
|
||||
@ -875,12 +944,13 @@ int hc_mtlReleaseMemObject (void *hashcat_ctx, mtl_mem *metal_buffer)
|
||||
|
||||
if (mtl == NULL) return -1;
|
||||
|
||||
if (metal_buffer == NULL || *metal_buffer == nil) return -1;
|
||||
if (mem == NULL || mem->buf_ptr == nil) return -1;
|
||||
|
||||
[*metal_buffer setPurgeableState:MTLPurgeableStateEmpty];
|
||||
[*metal_buffer release];
|
||||
[mem->buf_ptr setPurgeableState: MTLPurgeableStateEmpty];
|
||||
|
||||
*metal_buffer = nil;
|
||||
[mem->buf_ptr release];
|
||||
|
||||
mem->buf_ptr = nil;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -953,7 +1023,7 @@ int hc_mtlReleaseDevice (void *hashcat_ctx, mtl_device_id metal_device)
|
||||
|
||||
// device to device
|
||||
|
||||
int hc_mtlMemcpyDtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_mem buf_dst, size_t buf_dst_off, mtl_mem buf_src, size_t buf_src_off, size_t buf_size)
|
||||
int hc_mtlMemcpyDtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_mem_t mem_dst, size_t mem_dst_off, mtl_mem_t mem_src, size_t mem_src_off, size_t size)
|
||||
{
|
||||
if (command_queue == nil)
|
||||
{
|
||||
@ -962,55 +1032,62 @@ int hc_mtlMemcpyDtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_me
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_src == nil)
|
||||
if (mem_src.buf_ptr == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): metal src buffer is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_src_off < 0)
|
||||
if (mem_src_off < 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): src buffer offset is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_dst == nil)
|
||||
if (mem_dst.buf_ptr == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): metal dst buffer is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_dst_off < 0)
|
||||
if (mem_dst_off < 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): dst buffer offset is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_size <= 0)
|
||||
if (size <= 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): buffer size is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_src_off + buf_size > [buf_src length])
|
||||
if (mem_src_off + size > [mem_src.buf_ptr length])
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): src buffer offset + size out of bounds", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_dst_off + buf_size > [buf_dst length])
|
||||
if (mem_dst_off + size > [mem_dst.buf_ptr length])
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): dst buffer offset + size out of bounds", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mem_src.buf_mode != mem_dst.buf_mode)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): src and dst buffers using different storage modes", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
id<MTLCommandBuffer> command_buffer = [command_queue commandBuffer];
|
||||
|
||||
if (command_buffer == nil)
|
||||
@ -1030,11 +1107,19 @@ int hc_mtlMemcpyDtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_me
|
||||
|
||||
// copy
|
||||
|
||||
[blit_encoder copyFromBuffer: buf_src sourceOffset: buf_src_off toBuffer: buf_dst destinationOffset: buf_dst_off size: buf_size];
|
||||
[blit_encoder copyFromBuffer: mem_src.buf_ptr sourceOffset: mem_src_off toBuffer: mem_dst.buf_ptr destinationOffset: mem_dst_off size: size];
|
||||
|
||||
if (mem_dst.buf_mode == MTL_STORAGE_MODE_MANAGED)
|
||||
{
|
||||
// synchronize needed with MANAGED only
|
||||
|
||||
[blit_encoder synchronizeResource: mem_dst.buf_ptr];
|
||||
}
|
||||
|
||||
// finish encoding and start the data transfer
|
||||
|
||||
[blit_encoder endEncoding];
|
||||
|
||||
[command_buffer commit];
|
||||
|
||||
// Wait for complete
|
||||
@ -1046,7 +1131,7 @@ int hc_mtlMemcpyDtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_me
|
||||
|
||||
// host to device
|
||||
|
||||
int hc_mtlMemcpyHtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_mem buf_dst, size_t buf_dst_off, const void *buf_src, size_t buf_size)
|
||||
int hc_mtlMemcpyHtoD (void *hashcat_ctx, mtl_device_id metal_device, mtl_command_queue command_queue, mtl_mem_t mem_dst, size_t mem_dst_off, const void *host_buf_src, size_t size)
|
||||
{
|
||||
if (command_queue == nil)
|
||||
{
|
||||
@ -1055,67 +1140,121 @@ int hc_mtlMemcpyHtoD (void *hashcat_ctx, mtl_command_queue command_queue, mtl_me
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_src == nil)
|
||||
if (host_buf_src == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): metal src buffer is invalid", __func__);
|
||||
event_log_error (hashcat_ctx, "%s(): host src buffer is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_dst == nil)
|
||||
if (mem_dst.buf_ptr == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): host dst buffer is invalid", __func__);
|
||||
event_log_error (hashcat_ctx, "%s(): metal dst buffer is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_size <= 0)
|
||||
if (size <= 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): buffer size is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_dst_off < 0)
|
||||
if (mem_dst_off < 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): buffer dst offset is invalid", __func__);
|
||||
event_log_error (hashcat_ctx, "%s(): metal dst offset is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_dst_off + buf_size > [buf_dst length])
|
||||
if (mem_dst_off + size > [mem_dst.buf_ptr length])
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): buffer offset + size out of bounds", __func__);
|
||||
event_log_error (hashcat_ctx, "%s(): metal dst offset + size out of bounds", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *buf_dst_ptr = [buf_dst contents];
|
||||
|
||||
if (buf_dst_ptr == nil)
|
||||
if (mem_dst.buf_mode == MTL_STORAGE_MODE_PRIVATE)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get metal buffer data pointer", __func__);
|
||||
id<MTLBuffer> staging_buf = [metal_device newBufferWithLength: size options: MTLResourceStorageModeShared];
|
||||
|
||||
if (staging_buf == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to create staging buffer", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *staging_buf_ptr = [staging_buf contents];
|
||||
|
||||
if (staging_buf_ptr == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get staging buffer ptr", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy (staging_buf_ptr, host_buf_src, size);
|
||||
|
||||
id<MTLCommandBuffer> command_buffer = [command_queue commandBuffer];
|
||||
|
||||
if (command_buffer == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to create a new command buffer", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
id<MTLBlitCommandEncoder> blit_encoder = [command_buffer blitCommandEncoder];
|
||||
|
||||
if (blit_encoder == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to create a blit command encoder", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
[blit_encoder copyFromBuffer: staging_buf sourceOffset: 0 toBuffer: mem_dst.buf_ptr destinationOffset: mem_dst_off size: size];
|
||||
|
||||
[blit_encoder endEncoding];
|
||||
|
||||
[command_buffer commit];
|
||||
|
||||
[command_buffer waitUntilCompleted];
|
||||
|
||||
[staging_buf release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *mem_dst_ptr = [mem_dst.buf_ptr contents];
|
||||
|
||||
if (mem_dst_ptr == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get metal dst ptr", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (memcpy (buf_dst_ptr + buf_dst_off, buf_src, buf_size) != buf_dst_ptr + buf_dst_off)
|
||||
if (memcpy (mem_dst_ptr + mem_dst_off, host_buf_src, size) != mem_dst_ptr + mem_dst_off)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): memcpy failed", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// On macOS Intel, for Managed storage, notify GPU of modified range. Not on Apple Silicon
|
||||
|
||||
[buf_dst didModifyRange: NSMakeRange (buf_dst_off, buf_size)];
|
||||
if (mem_dst.buf_mode == MTL_STORAGE_MODE_MANAGED)
|
||||
{
|
||||
[mem_dst.buf_ptr didModifyRange: NSMakeRange (mem_dst_off, size)];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// device to host
|
||||
|
||||
int hc_mtlMemcpyDtoH (void *hashcat_ctx, mtl_command_queue command_queue, void *buf_dst, mtl_mem buf_src, size_t buf_src_off, size_t buf_size)
|
||||
int hc_mtlMemcpyDtoH (void *hashcat_ctx, mtl_device_id metal_device, mtl_command_queue command_queue, void *host_buf_dst, mtl_mem_t mem_src, size_t mem_src_off, size_t size)
|
||||
{
|
||||
if (command_queue == nil)
|
||||
{
|
||||
@ -1124,34 +1263,71 @@ int hc_mtlMemcpyDtoH (void *hashcat_ctx, mtl_command_queue command_queue, void *
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_src == nil)
|
||||
if (mem_src.buf_ptr == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): metal src buffer is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_dst == nil)
|
||||
if (host_buf_dst == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): host dst buffer is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_size <= 0)
|
||||
if (size <= 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): buffer size is invalid", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf_src_off + buf_size > [buf_src length])
|
||||
if (mem_src_off + size > [mem_src.buf_ptr length])
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): buffer offset + size out of bounds", __func__);
|
||||
event_log_error (hashcat_ctx, "%s(): metal src offset + size out of bounds", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mem_src.buf_mode == MTL_STORAGE_MODE_SHARED)
|
||||
{
|
||||
// get src buf ptr
|
||||
|
||||
void *mem_src_ptr = [mem_src.buf_ptr contents];
|
||||
|
||||
if (mem_src_ptr == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get metal src ptr", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (memcpy (host_buf_dst, mem_src_ptr + mem_src_off, size) != host_buf_dst)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): memcpy failed", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
id<MTLBuffer> staging_buf = nil;
|
||||
|
||||
if (mem_src.buf_mode == MTL_STORAGE_MODE_PRIVATE)
|
||||
{
|
||||
staging_buf = [metal_device newBufferWithLength: size options: MTLResourceStorageModeShared];
|
||||
|
||||
if (staging_buf == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to create staging buffer", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
id<MTLCommandBuffer> command_buffer = [command_queue commandBuffer];
|
||||
|
||||
if (command_buffer == nil)
|
||||
@ -1163,37 +1339,73 @@ int hc_mtlMemcpyDtoH (void *hashcat_ctx, mtl_command_queue command_queue, void *
|
||||
|
||||
id<MTLBlitCommandEncoder> blit_encoder = [command_buffer blitCommandEncoder];
|
||||
|
||||
// On macOS Intel, for Managed storage, synchronizeResource. Not on Apple Silicon
|
||||
if (blit_encoder == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to create a blit command encoder", __func__);
|
||||
|
||||
[blit_encoder synchronizeResource: buf_src];
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Finish encoding and start the data transfer to the CPU
|
||||
if (mem_src.buf_mode == MTL_STORAGE_MODE_MANAGED)
|
||||
{
|
||||
[blit_encoder synchronizeResource: mem_src.buf_ptr];
|
||||
}
|
||||
else
|
||||
{
|
||||
[blit_encoder copyFromBuffer: mem_src.buf_ptr sourceOffset: mem_src_off toBuffer: staging_buf destinationOffset: 0 size: size];
|
||||
}
|
||||
|
||||
[blit_encoder endEncoding];
|
||||
[command_buffer commit];
|
||||
|
||||
// Wait for complete
|
||||
[command_buffer commit];
|
||||
|
||||
[command_buffer waitUntilCompleted];
|
||||
|
||||
// get src buf ptr
|
||||
|
||||
void *buf_src_ptr = [buf_src contents];
|
||||
|
||||
if (buf_src_ptr == nil)
|
||||
if (mem_src.buf_mode == MTL_STORAGE_MODE_MANAGED)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get metal buffer data pointer", __func__);
|
||||
// get src buf ptr
|
||||
|
||||
void *mem_src_ptr = [mem_src.buf_ptr contents];
|
||||
|
||||
if (mem_src_ptr == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get metal src ptr", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (memcpy (host_buf_dst, mem_src_ptr + mem_src_off, size) != host_buf_dst)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): memcpy failed", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// PRIVATE
|
||||
|
||||
void *staging_buf_ptr = [staging_buf contents];
|
||||
|
||||
if (staging_buf_ptr == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): failed to get staging buffer ptr", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (memcpy (buf_dst, buf_src_ptr + buf_src_off, buf_size) != buf_dst)
|
||||
if (memcpy (host_buf_dst, staging_buf_ptr, size) != host_buf_dst)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): memcpy failed", __func__);
|
||||
|
||||
[staging_buf release];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
[staging_buf release];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1310,13 +1522,14 @@ int hc_mtlEncodeComputeCommand_pre (void *hashcat_ctx, mtl_pipeline metal_pipeli
|
||||
|
||||
[metal_commandEncoder setComputePipelineState: metal_pipeline];
|
||||
|
||||
*metal_command_buffer = metal_commandBuffer;
|
||||
*metal_command_buffer = metal_commandBuffer;
|
||||
|
||||
*metal_command_encoder = metal_commandEncoder;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hc_mtlSetCommandEncoderArg (void *hashcat_ctx, mtl_command_encoder metal_command_encoder, size_t off, size_t idx, mtl_mem buf, void *host_data, size_t host_data_size)
|
||||
int hc_mtlSetCommandEncoderArg (void *hashcat_ctx, mtl_command_encoder metal_command_encoder, size_t off, size_t idx, id mem, void *host_data, size_t host_data_size)
|
||||
{
|
||||
if (metal_command_encoder == nil)
|
||||
{
|
||||
@ -1325,14 +1538,15 @@ int hc_mtlSetCommandEncoderArg (void *hashcat_ctx, mtl_command_encoder metal_com
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf == nil && host_data == nil)
|
||||
// host_data can be objective-c object (so use nil) or C pointer (so use NULL)
|
||||
if (mem == nil && host_data == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): invalid buf/host_data", __func__);
|
||||
event_log_error (hashcat_ctx, "%s(): invalid mem/host_data", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (buf == nil)
|
||||
if (mem == nil)
|
||||
{
|
||||
if (host_data_size <= 0)
|
||||
{
|
||||
@ -1353,14 +1567,15 @@ int hc_mtlSetCommandEncoderArg (void *hashcat_ctx, mtl_command_encoder metal_com
|
||||
|
||||
if (idx < 0)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): invalid buf/host_data idx", __func__);
|
||||
event_log_error (hashcat_ctx, "%s(): invalid mem/host_data idx", __func__);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// host_data can be objective-c object (so use nil) or C pointer (so use NULL)
|
||||
if (host_data == nil)
|
||||
{
|
||||
[metal_command_encoder setBuffer: buf offset: off atIndex: idx];
|
||||
[metal_command_encoder setBuffer: mem offset: off atIndex: idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1372,20 +1587,6 @@ int hc_mtlSetCommandEncoderArg (void *hashcat_ctx, mtl_command_encoder metal_com
|
||||
|
||||
int hc_mtlEncodeComputeCommand (void *hashcat_ctx, mtl_command_encoder metal_command_encoder, mtl_command_buffer metal_command_buffer, const unsigned int work_dim, const size_t global_work_size[3], const size_t local_work_size[3], double *ms)
|
||||
{
|
||||
MTLSize threadsPerThreadgroup =
|
||||
{
|
||||
local_work_size[0],
|
||||
local_work_size[1],
|
||||
local_work_size[2]
|
||||
};
|
||||
|
||||
MTLSize threadgroupsPerGrid =
|
||||
{
|
||||
(global_work_size[0] + threadsPerThreadgroup.width - 1) / threadsPerThreadgroup.width,
|
||||
work_dim > 1 ? (global_work_size[1] + threadsPerThreadgroup.height - 1) / threadsPerThreadgroup.height : 1,
|
||||
work_dim > 2 ? (global_work_size[2] + threadsPerThreadgroup.depth - 1) / threadsPerThreadgroup.depth : 1
|
||||
};
|
||||
|
||||
if (metal_command_encoder == nil)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): invalid metal_command_encoder", __func__);
|
||||
@ -1400,6 +1601,20 @@ int hc_mtlEncodeComputeCommand (void *hashcat_ctx, mtl_command_encoder metal_com
|
||||
return -1;
|
||||
}
|
||||
|
||||
MTLSize threadsPerThreadgroup =
|
||||
{
|
||||
local_work_size[0],
|
||||
local_work_size[1],
|
||||
local_work_size[2]
|
||||
};
|
||||
|
||||
MTLSize threadgroupsPerGrid =
|
||||
{
|
||||
(global_work_size[0] + threadsPerThreadgroup.width - 1) / threadsPerThreadgroup.width,
|
||||
work_dim > 1 ? (global_work_size[1] + threadsPerThreadgroup.height - 1) / threadsPerThreadgroup.height : 1,
|
||||
work_dim > 2 ? (global_work_size[2] + threadsPerThreadgroup.depth - 1) / threadsPerThreadgroup.depth : 1
|
||||
};
|
||||
|
||||
[metal_command_encoder dispatchThreadgroups: threadgroupsPerGrid threadsPerThreadgroup: threadsPerThreadgroup];
|
||||
|
||||
[metal_command_encoder endEncoding];
|
||||
@ -1433,7 +1648,7 @@ int hc_mtlCreateLibraryWithFile (void *hashcat_ctx, mtl_device_id metal_device,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cached_file == nil)
|
||||
if (cached_file == NULL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "%s(): invalid metallib", __func__);
|
||||
|
||||
@ -1448,7 +1663,7 @@ int hc_mtlCreateLibraryWithFile (void *hashcat_ctx, mtl_device_id metal_device,
|
||||
|
||||
if (libURL != nil)
|
||||
{
|
||||
id <MTLLibrary> r = [metal_device newLibraryWithURL: libURL error:&error];
|
||||
id <MTLLibrary> metal_library_tmp = [metal_device newLibraryWithURL: libURL error: &error];
|
||||
|
||||
if (error != nil)
|
||||
{
|
||||
@ -1457,7 +1672,7 @@ int hc_mtlCreateLibraryWithFile (void *hashcat_ctx, mtl_device_id metal_device,
|
||||
return -1;
|
||||
}
|
||||
|
||||
*metal_library = r;
|
||||
*metal_library = metal_library_tmp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1478,7 +1693,7 @@ int hc_mtlCreateLibraryWithSource (void *hashcat_ctx, mtl_device_id metal_device
|
||||
|
||||
NSMutableDictionary *build_options_dict = nil;
|
||||
|
||||
if (build_options_buf != nil)
|
||||
if (build_options_buf != NULL)
|
||||
{
|
||||
//printf ("using build_opts from arg:\n%s\n", build_options_buf);
|
||||
|
||||
@ -1547,14 +1762,16 @@ int hc_mtlCreateLibraryWithSource (void *hashcat_ctx, mtl_device_id metal_device
|
||||
compileOptions.languageVersion = MTL_LANGUAGEVERSION_1_1;
|
||||
}
|
||||
*/
|
||||
id<MTLLibrary> r = [metal_device newLibraryWithSource: k_string options: compileOptions error: &error];
|
||||
id<MTLLibrary> metal_library_tmp = [metal_device newLibraryWithSource: k_string options: compileOptions error: &error];
|
||||
|
||||
[compileOptions release];
|
||||
|
||||
compileOptions = nil;
|
||||
|
||||
if (build_options_dict != nil)
|
||||
{
|
||||
[build_options_dict release];
|
||||
|
||||
build_options_dict = nil;
|
||||
}
|
||||
|
||||
@ -1565,7 +1782,7 @@ int hc_mtlCreateLibraryWithSource (void *hashcat_ctx, mtl_device_id metal_device
|
||||
return -1;
|
||||
}
|
||||
|
||||
*metal_library = r;
|
||||
*metal_library = metal_library_tmp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ int check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pla
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
rc = hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, tmps, device_param->metal_d_tmps, plain->gidvid * hashconfig->tmp_size, hashconfig->tmp_size);
|
||||
rc = hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, tmps, device_param->metal_d_tmps, plain->gidvid * hashconfig->tmp_size, hashconfig->tmp_size);
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
@ -602,7 +602,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, &num_cracked, device_param->metal_d_result, 0, sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, &num_cracked, device_param->metal_d_result, 0, sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -659,7 +659,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
rc = hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, cracked, device_param->metal_d_plain_bufs, 0, num_cracked * sizeof (plain_t));
|
||||
rc = hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, cracked, device_param->metal_d_plain_bufs, 0, num_cracked * sizeof (plain_t));
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
|
@ -39,9 +39,9 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params[15] = device_param->metal_d_st_digests_buf;
|
||||
device_param->kernel_params[17] = device_param->metal_d_st_salts_buf;
|
||||
device_param->kernel_params[18] = device_param->metal_d_st_esalts_buf;
|
||||
device_param->kernel_params[15] = device_param->metal_d_st_digests_buf.buf_ptr;
|
||||
device_param->kernel_params[17] = device_param->metal_d_st_salts_buf.buf_ptr;
|
||||
device_param->kernel_params[18] = device_param->metal_d_st_esalts_buf.buf_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -114,7 +114,7 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -159,7 +159,7 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -233,9 +233,9 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_combs_c, 0, &comb, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_combs_c, 0, &comb, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -280,7 +280,7 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -341,7 +341,7 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_bfs_c, 0, &bf, 1 * sizeof (bf_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_bfs_c, 0, &bf, 1 * sizeof (bf_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -447,7 +447,7 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -485,7 +485,7 @@ static int selftest_init (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_pws_buf, 0, &pw, 1 * sizeof (pw_t)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -602,7 +602,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, device_param->size_hooks) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, device_param->size_hooks) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -627,7 +627,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, device_param->size_hooks) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, device_param->size_hooks) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -698,7 +698,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -739,7 +739,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -773,7 +773,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, device_param->size_hooks) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->hooks_buf, device_param->metal_d_hooks, 0, device_param->size_hooks) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -798,7 +798,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, device_param->size_hooks) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_hooks, 0, device_param->hooks_buf, device_param->size_hooks) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -861,7 +861,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->h_tmps, device_param->metal_d_tmps, 0, hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -898,7 +898,7 @@ static int selftest_run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *d
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, hashconfig->tmp_size) == -1) return -1;
|
||||
if (hc_mtlMemcpyHtoD (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, device_param->metal_d_tmps, 0, device_param->h_tmps, hashconfig->tmp_size) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -977,7 +977,7 @@ static int selftest_cleanup (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_command_queue, num_cracked, device_param->metal_d_result, 0, sizeof (u32)) == -1) return -1;
|
||||
if (hc_mtlMemcpyDtoH (hashcat_ctx, device_param->metal_device, device_param->metal_command_queue, num_cracked, device_param->metal_d_result, 0, sizeof (u32)) == -1) return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1030,9 +1030,9 @@ static int selftest_cleanup (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *devi
|
||||
#if defined (__APPLE__)
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
device_param->kernel_params[15] = device_param->metal_d_digests_buf;
|
||||
device_param->kernel_params[17] = device_param->metal_d_salt_bufs;
|
||||
device_param->kernel_params[18] = device_param->metal_d_esalt_bufs;
|
||||
device_param->kernel_params[15] = device_param->metal_d_digests_buf.buf_ptr;
|
||||
device_param->kernel_params[17] = device_param->metal_d_salt_bufs.buf_ptr;
|
||||
device_param->kernel_params[18] = device_param->metal_d_esalt_bufs.buf_ptr;
|
||||
|
||||
if (run_metal_kernel_bzero (hashcat_ctx, device_param, device_param->metal_d_pws_buf, device_param->size_pws) == -1) return -1;
|
||||
if (run_metal_kernel_bzero (hashcat_ctx, device_param, device_param->metal_d_tmps, device_param->size_tmps) == -1) return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user