Skip to content

Commit 35a4c2d

Browse files
ssjiajpiat
authored andcommitted
[ET-VK] Fix VMA assertion caused by bool return type truncation
The `test_host_cached_available` function in Allocator.cpp was introduced in D95836687 with a `bool` return type, but its return statements return `VmaAllocationCreateFlags` values (`VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT` = 0x1000 and `VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT` = 0x800). The `bool` return type truncates both to `1`, which equals `VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT` — not a host access flag. This caused VMA to assert when allocating host-mapped staging buffers because the allocation had `MAPPED_BIT` + `AUTO_PREFER_HOST` but no host access flag. Fix the return type from `bool` to `VmaAllocationCreateFlags` so the correct flag values are preserved. Differential Revision: [D96151798](https://our.internmc.facebook.com/intern/diff/D96151798/) ghstack-source-id: 350606504 Pull Request resolved: pytorch#18105
1 parent ef5ec2c commit 35a4c2d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

backends/vulkan/runtime/vk_api/memory/Allocator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
namespace vkcompute {
1212
namespace vkapi {
1313

14-
bool test_host_cached_available(VkPhysicalDevice physical_device) {
14+
VmaAllocationCreateFlags test_host_cached_available(
15+
VkPhysicalDevice physical_device) {
1516
VkPhysicalDeviceMemoryProperties mem_props;
1617
vkGetPhysicalDeviceMemoryProperties(physical_device, &mem_props);
1718

0 commit comments

Comments
 (0)