-
Notifications
You must be signed in to change notification settings - Fork 12.2k
vulkan: Find optimal memory type but with fallback #5381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7a37ab8
to
08bf455
Compare
For staging buffers we could probably just drop the cached requirement alltogether, since they only do memcpys to and from cpu. But overall this approach is probably a good idea and corresponds with something that VMA does. I'll give it a try soon and do a review. Thank you for your work! |
I think it would be better to just add a fallback buffer type to the |
Thanks for the review @0cc4m. For my understanding: are you suggesting we should always fallback to HOST_VISIBLE/COHERENT in memory_type_index = find_properties(&mem_props, &mem_req, req_flags);
if (memory_type_index == -1) {
memory_type_index = find_properties(&mem_props, &mem_req, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent);
} |
I mean instead of having required flags and desired flags we could just allow having two pairs of flags. If the first isn't available, fall back to the second. If that isn't available, throw an error. If the second set is empty, throw an error after the first fails. static vk_buffer ggml_vk_create_buffer(ggml_backend_vk_context * ctx, size_t size, vk::MemoryPropertyFlags req_flags, vk::MemoryPropertyFlags fallback_flags = vk::MemoryPropertyFlags(0)) {
[...]
memory_type_index = find_properties(&mem_props, &mem_req, req_flags);
if (memory_type_index == -1 && fallback_flags != 0) {
memory_type_index = find_properties(&mem_props, &mem_req, fallback_flags);
} Something like this. |
9597782
to
8994ac8
Compare
Thank you, looks good now. |
Some memory properties are nice to have, but not critical.
eHostCached
, for instance, isn't essential, and yet we fail on devices where this memory property isn't available.This change differentiates between those properties that are critical and those that are just nice-to-have, and will fail only when critical properties aren't available.
Fixes #5319.