From 43838d86d703f778c251563e6adc22af523379df Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 5 Dec 2025 19:59:47 +0200 Subject: [PATCH] metal : fix build --- ggml/src/ggml-metal/ggml-metal-device.m | 28 ++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/ggml/src/ggml-metal/ggml-metal-device.m b/ggml/src/ggml-metal/ggml-metal-device.m index c53ec506cd..2118efb614 100644 --- a/ggml/src/ggml-metal/ggml-metal-device.m +++ b/ggml/src/ggml-metal/ggml-metal-device.m @@ -574,22 +574,26 @@ ggml_metal_rsets_t ggml_metal_rsets_init(void) { // the requests stop after a certain amount of time (keep_alive_s) of inactivity dispatch_queue_t d_queue = dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0); dispatch_group_async(res->d_group, d_queue, ^{ - while (!atomic_load_explicit(&res->d_stop, memory_order_relaxed)) { - if (atomic_load_explicit(&res->d_loop, memory_order_relaxed) > 0) { - [res->lock lock]; +#if defined(GGML_METAL_HAS_RESIDENCY_SETS) + if (@available(macOS 15.0, iOS 18.0, tvOS 18.0, visionOS 2.0, *)) { + while (!atomic_load_explicit(&res->d_stop, memory_order_relaxed)) { + if (atomic_load_explicit(&res->d_loop, memory_order_relaxed) > 0) { + [res->lock lock]; - for (int i = 0; i < (int) res->data.count; ++i) { - [res->data[i] requestResidency]; - } + for (int i = 0; i < (int) res->data.count; ++i) { + [res->data[i] requestResidency]; + } - atomic_fetch_sub_explicit(&res->d_loop, 1, memory_order_relaxed); + atomic_fetch_sub_explicit(&res->d_loop, 1, memory_order_relaxed); - [res->lock unlock]; - } + [res->lock unlock]; + } - // half a second - usleep(500 * 1000); - } + // half a second + usleep(500 * 1000); + } + } +#endif }); return res;