Skip to content

Commit c579d6c

Browse files
jhen0409mglambda
authored andcommitted
metal : use residency set for other platforms (ggml-org#11648)
1 parent 70650ec commit c579d6c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
#define GGML_METAL_MAX_COMMAND_BUFFERS 8
2121

2222
// create residency sets only on macOS >= 15.0
23-
#if TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000
23+
#if TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000 || \
24+
TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000 || \
25+
TARGET_OS_TV && __TV_OS_VERSION_MAX_ALLOWED >= 180000 || \
26+
TARGET_OS_VISION && __VISION_OS_VERSION_MAX_ALLOWED >= 200000
2427
#define GGML_METAL_HAS_RESIDENCY_SETS 1
2528
#endif
2629

@@ -1071,7 +1074,7 @@ static bool ggml_backend_metal_buffer_rset_init(
10711074
}
10721075

10731076
#if defined(GGML_METAL_HAS_RESIDENCY_SETS)
1074-
if (@available(macOS 15.0, *)) {
1077+
if (@available(macOS 15.0, iOS 18.0, tvOS 18.0, visionOS 2.0, *)) {
10751078
MTLResidencySetDescriptor * desc = [[MTLResidencySetDescriptor alloc] init];
10761079
desc.label = @"ggml_backend_metal";
10771080
desc.initialCapacity = ctx->n_buffers;
@@ -1106,7 +1109,7 @@ static bool ggml_backend_metal_buffer_rset_init(
11061109
// rset free
11071110
static void ggml_backend_metal_buffer_rset_free(struct ggml_backend_metal_buffer_context * ctx) {
11081111
#if defined(GGML_METAL_HAS_RESIDENCY_SETS)
1109-
if (@available(macOS 15.0, *)) {
1112+
if (@available(macOS 15.0, iOS 18.0, tvOS 18.0, visionOS 2.0, *)) {
11101113
if (ctx->rset) {
11111114
[ctx->rset endResidency];
11121115
[ctx->rset removeAllAllocations];

0 commit comments

Comments
 (0)