@@ -369,8 +369,11 @@ static void ggml_metal_log(enum ggml_log_level level, const char * format, ...){
369
369
GGML_METAL_LOG_INFO (" %s : simdgroup reduction support = %s \n " , __func__, ctx->support_simdgroup_reduction ? " true" : " false" );
370
370
GGML_METAL_LOG_INFO (" %s : simdgroup matrix mul. support = %s \n " , __func__, ctx->support_simdgroup_mm ? " true" : " false" );
371
371
GGML_METAL_LOG_INFO (" %s : hasUnifiedMemory = %s \n " , __func__, ctx->device .hasUnifiedMemory ? " true" : " false" );
372
+
373
+ if (@available (macOS 10.12 , iOS 16.0 , *)) {
374
+ GGML_METAL_LOG_INFO (" %s : recommendedMaxWorkingSetSize = %8.2f MB\n " , __func__, ctx->device .recommendedMaxWorkingSetSize / 1e6 );
375
+ }
372
376
#if TARGET_OS_OSX
373
- GGML_METAL_LOG_INFO (" %s : recommendedMaxWorkingSetSize = %8.2f MB\n " , __func__, ctx->device .recommendedMaxWorkingSetSize / 1e6 );
374
377
if (ctx->device .maxTransferRate != 0 ) {
375
378
GGML_METAL_LOG_INFO (" %s : maxTransferRate = %8.2f MB/s\n " , __func__, ctx->device .maxTransferRate / 1e6 );
376
379
} else {
@@ -2369,6 +2372,22 @@ static void ggml_backend_metal_buffer_clear(ggml_backend_buffer_t buffer, uint8_
2369
2372
UNUSED (buft);
2370
2373
}
2371
2374
2375
+ static void ggml_backend_metal_log_allocated_size (id <MTLDevice > device) {
2376
+ if (@available (macOS 10.12 , iOS 16.0 , *)) {
2377
+ GGML_METAL_LOG_INFO (" , (%8.2f / %8.2f )" ,
2378
+ device.currentAllocatedSize / 1024.0 / 1024.0 ,
2379
+ device.recommendedMaxWorkingSetSize / 1024.0 / 1024.0 );
2380
+
2381
+ if (device.currentAllocatedSize > device.recommendedMaxWorkingSetSize ) {
2382
+ GGML_METAL_LOG_WARN (" %s : warning: current allocated size is greater than the recommended max working set size\n " , __func__);
2383
+ } else {
2384
+ GGML_METAL_LOG_INFO (" \n " );
2385
+ }
2386
+ } else {
2387
+ GGML_METAL_LOG_INFO (" , (%8.2f )\n " , device.currentAllocatedSize / 1024.0 / 1024.0 );
2388
+ }
2389
+ }
2390
+
2372
2391
static ggml_backend_buffer_t ggml_backend_metal_buffer_type_alloc_buffer (ggml_backend_buffer_type_t buft, size_t size) {
2373
2392
struct ggml_backend_metal_buffer_context * ctx = malloc (sizeof (struct ggml_backend_metal_buffer_context));
2374
2393
@@ -2401,22 +2420,7 @@ static ggml_backend_buffer_t ggml_backend_metal_buffer_type_alloc_buffer(ggml_ba
2401
2420
}
2402
2421
2403
2422
GGML_METAL_LOG_INFO (" %s : allocated buffer, size = %8.2f MiB" , __func__, size_aligned / 1024.0 / 1024.0 );
2404
-
2405
-
2406
- #if TARGET_OS_OSX
2407
- GGML_METAL_LOG_INFO (" , (%8.2f / %8.2f )" ,
2408
- device.currentAllocatedSize / 1024.0 / 1024.0 ,
2409
- device.recommendedMaxWorkingSetSize / 1024.0 / 1024.0 );
2410
-
2411
- if (device.currentAllocatedSize > device.recommendedMaxWorkingSetSize ) {
2412
- GGML_METAL_LOG_WARN (" %s : warning: current allocated size is greater than the recommended max working set size\n " , __func__);
2413
- } else {
2414
- GGML_METAL_LOG_INFO (" \n " );
2415
- }
2416
- #else
2417
- GGML_METAL_LOG_INFO (" , (%8.2f )\n " , device.currentAllocatedSize / 1024.0 / 1024.0 );
2418
- #endif
2419
-
2423
+ ggml_backend_metal_log_allocated_size (device);
2420
2424
2421
2425
return ggml_backend_buffer_init (buft, ggml_backend_metal_buffer_i, ctx, size);
2422
2426
}
@@ -2524,19 +2528,7 @@ ggml_backend_buffer_t ggml_backend_metal_buffer_from_ptr(void * data, size_t siz
2524
2528
}
2525
2529
}
2526
2530
2527
- #if TARGET_OS_OSX
2528
- GGML_METAL_LOG_INFO (" , (%8.2f / %8.2f )" ,
2529
- device.currentAllocatedSize / 1024.0 / 1024.0 ,
2530
- device.recommendedMaxWorkingSetSize / 1024.0 / 1024.0 );
2531
-
2532
- if (device.currentAllocatedSize > device.recommendedMaxWorkingSetSize ) {
2533
- GGML_METAL_LOG_WARN (" %s : warning: current allocated size is greater than the recommended max working set size\n " , __func__);
2534
- } else {
2535
- GGML_METAL_LOG_INFO (" \n " );
2536
- }
2537
- #else
2538
- GGML_METAL_LOG_INFO (" , (%8.2f )\n " , device.currentAllocatedSize / 1024.0 / 1024.0 );
2539
- #endif
2531
+ ggml_backend_metal_log_allocated_size (device);
2540
2532
2541
2533
return ggml_backend_buffer_init (ggml_backend_metal_buffer_type (), ggml_backend_metal_buffer_i, ctx, size);
2542
2534
}
0 commit comments