@@ -117,14 +117,17 @@ @implementation GGMLMetalClass
117
117
struct ggml_metal_context * ggml_metal_init (int n_cb) {
118
118
metal_printf (" %s : allocating\n " , __func__);
119
119
120
- // Show all the Metal device instances in the system
121
- NSArray * devices = MTLCopyAllDevices ();
122
120
id <MTLDevice > device;
123
121
NSString * s;
122
+
123
+ #if TARGET_OS_OSX
124
+ // Show all the Metal device instances in the system
125
+ NSArray * devices = MTLCopyAllDevices ();
124
126
for (device in devices) {
125
127
s = [device name ];
126
128
metal_printf (" %s : found device: %s \n " , __func__, [s UTF8String ]);
127
129
}
130
+ #endif
128
131
129
132
// Pick and show default Metal device
130
133
device = MTLCreateSystemDefaultDevice ();
@@ -247,13 +250,15 @@ @implementation GGMLMetalClass
247
250
#undef GGML_METAL_ADD_KERNEL
248
251
}
249
252
250
- metal_printf (" %s : recommendedMaxWorkingSetSize = %8.2f MB\n " , __func__, ctx->device .recommendedMaxWorkingSetSize / 1024.0 / 1024.0 );
251
253
metal_printf (" %s : hasUnifiedMemory = %s \n " , __func__, ctx->device .hasUnifiedMemory ? " true" : " false" );
254
+ #if TARGET_OS_OSX
255
+ metal_printf (" %s : recommendedMaxWorkingSetSize = %8.2f MB\n " , __func__, ctx->device .recommendedMaxWorkingSetSize / 1024.0 / 1024.0 );
252
256
if (ctx->device .maxTransferRate != 0 ) {
253
257
metal_printf (" %s : maxTransferRate = %8.2f MB/s\n " , __func__, ctx->device .maxTransferRate / 1024.0 / 1024.0 );
254
258
} else {
255
259
metal_printf (" %s : maxTransferRate = built-in GPU\n " , __func__);
256
260
}
261
+ #endif
257
262
258
263
return ctx;
259
264
}
@@ -454,6 +459,7 @@ bool ggml_metal_add_buffer(
454
459
}
455
460
}
456
461
462
+ #if TARGET_OS_OSX
457
463
metal_printf (" , (%8.2f / %8.2f )" ,
458
464
ctx->device .currentAllocatedSize / 1024.0 / 1024.0 ,
459
465
ctx->device .recommendedMaxWorkingSetSize / 1024.0 / 1024.0 );
@@ -463,6 +469,9 @@ bool ggml_metal_add_buffer(
463
469
} else {
464
470
metal_printf (" \n " );
465
471
}
472
+ #else
473
+ metal_printf (" , (%8.2f )\n " , ctx->device .currentAllocatedSize / 1024.0 / 1024.0 );
474
+ #endif
466
475
}
467
476
468
477
return true ;
0 commit comments