ggml_metal_init: Show all Metal device instances in the system
Also show the default Metal device that was picked.
This commit is contained in:
parent
4dcd47d71d
commit
339d3477bf
1 changed files with 16 additions and 1 deletions
17
ggml-metal.m
17
ggml-metal.m
|
@ -116,8 +116,23 @@ static NSString * const msl_library_source = @"see metal.metal";
|
|||
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 <MTLDevice> 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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue