Skip to content

Commit 4854fda

Browse files
committed
metal : check macOS version at compile time
ggml-ci
1 parent ebcad55 commit 4854fda

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ggml/src/ggml-metal/ggml-metal.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
bool has_simdgroup_reduction;
4141
bool has_simdgroup_mm;
42+
bool has_residency_sets;
4243
bool has_bfloat;
4344
bool use_bfloat;
4445

@@ -48,6 +49,7 @@
4849
/*.mtl_device_ref_count =*/ 0,
4950
/*.has_simdgroup_reduction =*/ false,
5051
/*.has_simdgroup_mm =*/ false,
52+
/*.has_residency_sets =*/ false,
5153
/*.has_bfloat =*/ false,
5254
/*.use_bfloat =*/ false,
5355
/*.name =*/ "",
@@ -65,6 +67,10 @@
6567

6668
ctx->has_simdgroup_mm = [ctx->mtl_device supportsFamily:MTLGPUFamilyApple7];
6769

70+
#if TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000
71+
ctx->has_residency_sets = true;
72+
#endif
73+
6874
ctx->has_bfloat = [ctx->mtl_device supportsFamily:MTLGPUFamilyMetal3_GGML];
6975
ctx->has_bfloat |= [ctx->mtl_device supportsFamily:MTLGPUFamilyApple6];
7076

@@ -654,6 +660,7 @@ @implementation GGMLMetalClass
654660

655661
GGML_LOG_INFO("%s: simdgroup reduction = %s\n", __func__, ctx_dev->has_simdgroup_reduction ? "true" : "false");
656662
GGML_LOG_INFO("%s: simdgroup matrix mul. = %s\n", __func__, ctx_dev->has_simdgroup_mm ? "true" : "false");
663+
GGML_LOG_INFO("%s: has residency sets = %s\n", __func__, ctx_dev->has_residency_sets ? "true" : "false");
657664
GGML_LOG_INFO("%s: has bfloat = %s\n", __func__, ctx_dev->has_bfloat ? "true" : "false");
658665
GGML_LOG_INFO("%s: use bfloat = %s\n", __func__, ctx_dev->use_bfloat ? "true" : "false");
659666
GGML_LOG_INFO("%s: hasUnifiedMemory = %s\n", __func__, ctx_dev->mtl_device.hasUnifiedMemory ? "true" : "false");
@@ -1047,7 +1054,7 @@ static void ggml_metal_free(struct ggml_backend_metal_context * ctx) {
10471054

10481055
// rset init
10491056
static bool ggml_backend_metal_buffer_rset_init(struct ggml_backend_metal_buffer_context * ctx, id<MTLDevice> device) {
1050-
#if TARGET_OS_OSX
1057+
#if TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000
10511058
// create residency sets only on macOS
10521059
if (@available(macOS 15.0, *)) {
10531060
MTLResidencySetDescriptor * desc;

0 commit comments

Comments
 (0)