sysgpu: fix vulkan find best allocator selecting smaller memory types #1445

Merged
shailpatels merged 1 commit from vulkan_find_best_allocator_fix into main 2026-02-28 22:52:42 +00:00
shailpatels commented 2026-02-20 01:40:14 +00:00 (Migrated from github.com)
  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.

This PR fixes an issue with the bulkan sysgpu find best allocator logic. When searching for a candidate memory type for .linear_write_mappable, only the memory bitflags are considered, which if a memory type with a smaller heap size was later in the list it would always be selected over.

Now the logic is updated if there is a best type already selected, the next candidate will only be considered if its heap size was strictly larger.

Similar logic has been applied for the .linear_read_mappable where the host visible bit would always cause the candidate to be selected. That has been removed since the top level if statement already checks for that.

in my case specifically, the last memory index was the GPU BAR region which is host visible but only has 256 MB heap space and was always getting selected causing the OutOfDeviceMemory error when ignoring regions with 10 and 25 GB of space.

here is an example of it working!
working

(and reproducing the bug)
bug

fixes #1352

- [X] By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right. ----- This PR fixes an issue with the bulkan sysgpu find best allocator logic. When searching for a candidate memory type for `.linear_write_mappable`, only the memory bitflags are considered, which if a memory type with a smaller heap size was later in the list it would always be selected over. Now the logic is updated if there is a best type already selected, the next candidate will only be considered if its heap size was strictly larger. Similar logic has been applied for the `.linear_read_mappable` where the host visible bit would always cause the candidate to be selected. That has been removed since the top level if statement already checks for that. in my case specifically, the last memory index was the GPU BAR region which is host visible but only has 256 MB heap space and was always getting selected causing the `OutOfDeviceMemory` error when ignoring regions with 10 and 25 GB of space. here is an example of it working! ![working](https://github.com/user-attachments/assets/4c89d8ae-216a-47ec-9b38-9faf76d49a91) (and reproducing the bug) ![bug](https://github.com/user-attachments/assets/e527bdc2-00fe-48f1-9859-72a442a96638) fixes #1352
emidoots (Migrated from github.com) approved these changes 2026-02-28 22:52:33 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach!1445
No description provided.