Skip to content

Commit 165caaf

Browse files
authored
metal: use shared buffers on eGPU (#17866)
* metal: use shared buffers on eGPU With #15906, I noticed on important regression when using metal backend on eGPU. This commit restore the previous behavior and add an option to force its activation. * metal: use shared buffers on eGPU * metal: use shared buffers on eGPU
1 parent 96a181a commit 165caaf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ggml/src/ggml-metal/ggml-metal-device.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,16 @@ ggml_metal_device_t ggml_metal_device_init(void) {
769769
#endif
770770

771771
dev->props.use_shared_buffers = dev->props.has_unified_memory;
772+
#if TARGET_OS_OSX
773+
// In case of eGPU, shared memory may be preferable.
774+
dev->props.use_shared_buffers |= [dev->mtl_device location] == MTLDeviceLocationExternal;
775+
#endif
772776
if (getenv("GGML_METAL_SHARED_BUFFERS_DISABLE") != NULL) {
773777
dev->props.use_shared_buffers = false;
774778
}
779+
if (getenv("GGML_METAL_SHARED_BUFFERS_ENABLE") != NULL) {
780+
dev->props.use_shared_buffers = true;
781+
}
775782

776783
dev->props.supports_gpu_family_apple7 = [dev->mtl_device supportsFamily:MTLGPUFamilyApple7];
777784

0 commit comments

Comments
 (0)