From 339d3477bfc3e0c8e38e6920754fd89327689568 Mon Sep 17 00:00:00 2001 From: Karsten Weiss Date: Fri, 1 Sep 2023 10:59:13 +0200 Subject: [PATCH 1/2] ggml_metal_init: Show all Metal device instances in the system Also show the default Metal device that was picked. --- ggml-metal.m | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ggml-metal.m b/ggml-metal.m index 8c3c64f53f00a..b9dc9a24e1df9 100644 --- a/ggml-metal.m +++ b/ggml-metal.m @@ -116,8 +116,23 @@ @implementation GGMLMetalClass struct ggml_metal_context * ggml_metal_init(int n_cb) { metal_printf("%s: allocating\n", __func__); - struct ggml_metal_context * ctx = malloc(sizeof(struct ggml_metal_context)); + // Show all the Metal device instances in the system + NSArray *devices = MTLCopyAllDevices(); + id device; + NSString *s; + for (device in devices) { + s = [device name]; + metal_printf("%s: found device: %s\n", __func__, [s UTF8String]); + } + // Pick and show default Metal device + device = MTLCreateSystemDefaultDevice(); + s = [device name]; + metal_printf("%s: picking default device: %s\n", __func__, [s UTF8String]); + + // Configure context + struct ggml_metal_context * ctx = malloc(sizeof(struct ggml_metal_context)); + ctx->device = device; ctx->n_cb = MIN(n_cb, GGML_METAL_MAX_BUFFERS); ctx->device = MTLCreateSystemDefaultDevice(); ctx->queue = [ctx->device newCommandQueue]; From 7930818a0ca2126b767d5f8526288333b86638c7 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sat, 2 Sep 2023 15:25:40 +0300 Subject: [PATCH 2/2] Update ggml-metal.m --- ggml-metal.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ggml-metal.m b/ggml-metal.m index b9dc9a24e1df9..6d94a4f673e3c 100644 --- a/ggml-metal.m +++ b/ggml-metal.m @@ -117,9 +117,9 @@ @implementation GGMLMetalClass metal_printf("%s: allocating\n", __func__); // Show all the Metal device instances in the system - NSArray *devices = MTLCopyAllDevices(); + NSArray * devices = MTLCopyAllDevices(); id device; - NSString *s; + NSString * s; for (device in devices) { s = [device name]; metal_printf("%s: found device: %s\n", __func__, [s UTF8String]); @@ -134,7 +134,6 @@ @implementation GGMLMetalClass struct ggml_metal_context * ctx = malloc(sizeof(struct ggml_metal_context)); ctx->device = device; ctx->n_cb = MIN(n_cb, GGML_METAL_MAX_BUFFERS); - ctx->device = MTLCreateSystemDefaultDevice(); ctx->queue = [ctx->device newCommandQueue]; ctx->n_buffers = 0; ctx->concur_list_len = 0;