Merge pull request #3531 from matrix/metal_compatibility

Allow using Metal < 300 with --force
pull/3536/head
Jens Steube 1 year ago committed by GitHub
commit 06af574dbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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;

@ -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

@ -16,6 +16,7 @@
#include <Foundation/Foundation.h>
#include <Metal/Metal.h>
/*
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)
{

@ -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);
}
char *metal_runtimeVersionStr = backend_ctx->metal_runtimeVersionStr;
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);

Loading…
Cancel
Save