mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-04 02:37:27 +02:00
metal : fix memory query under low-memory conditions (#27701)
* metal: Fix memory query under low-memory conditions * Simply variable name Co-authored-by: Georgi Gerganov <[email protected]> * Write it even shorter Co-authored-by: Niklas Wenzel <[email protected]> --------- Co-authored-by: Georgi Gerganov <[email protected]> Co-authored-by: Niklas Wenzel <[email protected]>
This commit is contained in:
co-authored by
Georgi Gerganov
Niklas Wenzel
parent
03dbcc53e1
commit
8c0b9cd04a
@@ -1471,8 +1471,10 @@ void ggml_metal_device_event_synchronize(ggml_metal_device_t dev, ggml_metal_eve
|
||||
|
||||
void ggml_metal_device_get_memory(ggml_metal_device_t dev, size_t * free, size_t * total) {
|
||||
if (@available(macOS 10.12, iOS 16.0, *)) {
|
||||
*total = dev->mtl_device.recommendedMaxWorkingSetSize;
|
||||
*free = *total - dev->mtl_device.currentAllocatedSize;
|
||||
*total = dev->mtl_device.recommendedMaxWorkingSetSize;
|
||||
size_t cur = dev->mtl_device.currentAllocatedSize;
|
||||
// it's possible to allocate more than `recommendedMaxWorkingSetSize`
|
||||
*free = *total > cur ? *total - cur : 0;
|
||||
} else {
|
||||
*free = 0;
|
||||
*total = 0;
|
||||
|
||||
Reference in New Issue
Block a user