llama.cpp/ggml
hung e459796110 fix: Metal backend performance on AMD discrete GPUs
Fixes two critical issues with Metal backend on AMD/Intel discrete GPUs:

1. Auto-disable concurrent dispatch on non-Apple GPUs
   - MTLDispatchTypeConcurrent has broken memory barriers on AMD
   - Causes L2 cache coherency issues leading to corrupted output
   - Now auto-detects via supports_gpu_family_apple7 and uses serial dispatch

2. Use Managed buffer mode on discrete GPUs for cached PCIe reads
   - Shared mode uses uncached PCIe reads (~3 MB/s) on discrete GPUs
   - Managed mode enables cached reads (~3 GB/s) with explicit sync
   - Adds didModifyRange after CPU writes, synchronizeResource for reads
   - Improves generation speed from ~11 t/s to ~60 t/s on AMD Radeon Pro 5300M

Performance on AMD Radeon Pro 5300M:
- Before: 11.5 t/s generation (corrupted output with concurrent dispatch)
- After: 60+ t/s generation (correct output, 88% of Vulkan performance)

Environment variable overrides for testing:
- GGML_METAL_MANAGED_BUFFERS_DISABLE/ENABLE
- GGML_METAL_CONCURRENCY_DISABLE (still works)

Also adds bench_metal.sh with benchmark and conversation modes.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 16:29:09 -05:00
..
cmake ggml: Skip backend library linking code when GGML_BACKEND_DL=ON (#15094) 2025-08-07 13:45:41 +02:00
include ggml-virtgpu: make the code thread safe (#19204) 2026-02-04 10:46:18 +08:00
src fix: Metal backend performance on AMD discrete GPUs 2026-02-11 16:29:09 -05:00
.gitignore vulkan : cmake integration (#8119) 2024-07-13 18:12:39 +02:00
CMakeLists.txt Bump cmake max version (needed for Windows on Snapdragon builds) (#19188) 2026-02-01 14:13:38 -08:00