diff --git a/OpenCL/inc_vendor.h b/OpenCL/inc_vendor.h index 0916a30b3..245f537fd 100644 --- a/OpenCL/inc_vendor.h +++ b/OpenCL/inc_vendor.h @@ -12,7 +12,7 @@ #define IS_CUDA #elif defined __HIPCC__ #define IS_HIP -#elif defined __METAL__ +#elif defined __METAL__ || defined __METAL_MACOS__ #define IS_METAL #else #define IS_OPENCL diff --git a/include/types.h b/include/types.h index 864e53a10..ce5270c6b 100644 --- a/include/types.h +++ b/include/types.h @@ -1640,8 +1640,8 @@ typedef struct hc_device_param #if defined (__APPLE__) - int mtl_major; - int mtl_minor; + //int mtl_major; + //int mtl_minor; int device_physical_location; int device_location_number; diff --git a/src/backend.c b/src/backend.c index 1b05d8934..d6e7ae38f 100644 --- a/src/backend.c +++ b/src/backend.c @@ -4505,7 +4505,11 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) if (hc_mtlRuntimeGetVersionString (hashcat_ctx, backend_ctx->metal_runtimeVersionStr, &version_len) == -1) return -1; - if (atoi (backend_ctx->metal_runtimeVersionStr) < 300) + backend_ctx->metal_runtimeVersion = atoi (backend_ctx->metal_runtimeVersionStr); + + // disable metal < 200 + + if (backend_ctx->metal_runtimeVersion < 200) { event_log_warning (hashcat_ctx, "Unsupported Apple Metal runtime version '%s' detected! Falling back to OpenCL...", backend_ctx->metal_runtimeVersionStr); event_log_warning (hashcat_ctx, NULL); @@ -4518,6 +4522,27 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) mtl_close (hashcat_ctx); } + else + { + if (user_options->force == false) + { + // disable metal < 300 + + if (backend_ctx->metal_runtimeVersion < 300) + { + event_log_warning (hashcat_ctx, "Unsupported Apple Metal runtime version '%s' detected! Falling back to OpenCL...", backend_ctx->metal_runtimeVersionStr); + event_log_warning (hashcat_ctx, NULL); + + rc_metal_init = -1; + + backend_ctx->rc_metal_init = rc_metal_init; + + backend_ctx->mtl = NULL; + + mtl_close (hashcat_ctx); + } + } + } } else { @@ -5827,29 +5852,28 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) device_param->opencl_device_vendor = strdup ("Apple"); device_param->opencl_device_c_version = ""; + /* unused and deprecated + // sm_minor, sm_major int mtl_major = 0; int mtl_minor = 0; - /* unused and deprecated if (hc_mtlDeviceGetAttribute (hashcat_ctx, &mtl_major, MTL_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, metal_device) == -1) { device_param->skipped = true; continue; } - */ - /* unused and deprecated if (hc_mtlDeviceGetAttribute (hashcat_ctx, &mtl_minor, MTL_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, metal_device) == -1) { device_param->skipped = true; continue; } - */ device_param->mtl_major = mtl_major; device_param->mtl_minor = mtl_minor; + */ // device_name diff --git a/src/ext_metal.m b/src/ext_metal.m index c894941c3..b8428369c 100644 --- a/src/ext_metal.m +++ b/src/ext_metal.m @@ -16,6 +16,7 @@ #include #include +/* typedef NS_ENUM(NSUInteger, hc_mtlFeatureSet) { MTL_FEATURESET_MACOS_GPUFAMILY_1_V1 = 10000, @@ -25,6 +26,7 @@ typedef NS_ENUM(NSUInteger, hc_mtlFeatureSet) MTL_FEATURESET_MACOS_GPUFAMILY_2_V1 = 10005, } metalDeviceFeatureSet_macOS_t; +*/ typedef NS_ENUM(NSUInteger, hc_mtlLanguageVersion) { diff --git a/src/terminal.c b/src/terminal.c index 614852db7..2de912e0a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1221,18 +1221,10 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, NULL); int metal_devices_cnt = backend_ctx->metal_devices_cnt; - int metal_runtimeVersion = backend_ctx->metal_runtimeVersion; + char *metal_runtimeVersionStr = backend_ctx->metal_runtimeVersionStr; - if (metal_runtimeVersionStr != NULL) - { - event_log_info (hashcat_ctx, "Metal.Version.: %s", metal_runtimeVersionStr); - } - else - { - event_log_info (hashcat_ctx, "Metal.Version.: %u", metal_runtimeVersion); - } - + event_log_info (hashcat_ctx, "Metal.Version.: %s", metal_runtimeVersionStr); event_log_info (hashcat_ctx, NULL); for (int metal_devices_idx = 0; metal_devices_idx < metal_devices_cnt; metal_devices_idx++) @@ -1242,8 +1234,8 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) const hc_device_param_t *device_param = backend_ctx->devices_param + backend_devices_idx; int device_id = device_param->device_id; - int device_mtl_maj = device_param->mtl_major; - int device_mtl_min = device_param->mtl_minor; + //int device_mtl_maj = device_param->mtl_major; + //int device_mtl_min = device_param->mtl_minor; int device_max_transfer_rate = device_param->device_max_transfer_rate; int device_physical_location = device_param->device_physical_location; int device_location_number = device_param->device_location_number; @@ -1293,6 +1285,7 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) default: event_log_info (hashcat_ctx, " Phys.Location..: N/A"); break; } + /* if (device_mtl_maj > 0 && device_mtl_min > 0) { event_log_info (hashcat_ctx, " Feature.Set....: macOS GPU Family %u v%u", device_mtl_maj, device_mtl_min); @@ -1301,6 +1294,7 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) { event_log_info (hashcat_ctx, " Feature.Set....: N/A"); } + */ event_log_info (hashcat_ctx, " Registry.ID....: %u", device_registryID); @@ -1542,6 +1536,7 @@ void backend_info_compact (hashcat_ctx_t *hashcat_ctx) if (backend_ctx->mtl) { int metal_devices_cnt = backend_ctx->metal_devices_cnt; + char *metal_runtimeVersionStr = backend_ctx->metal_runtimeVersionStr; size_t len = event_log_info (hashcat_ctx, "METAL API (Metal %s)", metal_runtimeVersionStr);