Repository navigation
Description
The current Vulkan HAL is some of the oldest code in IREE and it's been on life support for awhile. It's coming time to swap over to a new implementation that picks up some new min-spec features. Of major concern with the existing implementation is that it does not support async, does not support multiple devices, has 32-bit buffer size limitations on some targets, cannot support reusable command buffers, and (poorly) manages descriptor sets in a way that is not compatible with all other backends. A new version would be written in C targeting Vulkan 1.2+ and support VK_KHR_device_group and VK_KHR_buffer_device_address natively.
Major Work
- Define a parameter buffer ABI
- Implement support in the compiler for mapping bindings to the parameter buffer
- Define how binding table scatters can update the parameter buffer
- Add a new experimental skeleton HAL impl
- Preserve wrapping/extension mechanisms (needs to complete porting to C)
- Adjust enumeration to support device groups
- Port allocator and buffer types (temporarily)
- Implement proper SPIR-V module linking
- Compiler side needs to link
- Flatbuffers need to model linkage (and good time for other cleanup)
- Investigate pipeline libraries to see if they can be stubbed for future use
- Implement device queues (multiple queues per physical device, multiple physical devices)
- Queue management for pending submissions/cleanup
- Design/implement parameter ringbuffers (for per-submission staging of binding tables)
Implementation Features
Vulkan 1.2
This makes timeline semaphores core and we'll no longer need an extension to support them. There's probably some other things we can roll in as well and simplify extension checking. Some SPIR-V interop features like (VK_KHR_uniform_buffer_standard_layout)[https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_uniform_buffer_standard_layout.html] may also be useful for parameter buffers.
VK_KHR_buffer_device_address
(relevant to #13945 and #17875)
Descriptor sets are painful to manage even with update-after-bind semantics. They also don't with async/concurrent reusable command buffers requiring that we maintain fixed sets of descriptors with synchronous host updates and have those baked into command buffers - that prevents pipelining of submissions (as we can't update the descriptor sets while they are in use on any queue). Certain implementations (AMD) also cannot fully address buffers via descriptor sets and require device addresses.
By switching to using device addresses we gain the ability to manage our own parameter buffer pools, avoid pipeline layout compatibility complexity (which we currently implement incorrectly), can use full device addresses, and can produce reusable command buffers that are ordered on the queue timeline (by issuing async copies into parameter buffers in-queue).
This requires emitting shaders to use device addresses with our own parameter ABI as we already do for CUDA/HIP (but better than those, as those don't currently support binding table reuse - see #17875 for the CUDA/HIP graphs plan there).
VK_KHR_device_group
(relevant to #10765)
We want to be able to expose multiple physical devices as distinct logical queues under the same logical HAL device. This allows for low-overhead interop between the devices when sharding across multiple devices attached to the same node. Device groups are how Vulkan represents this: allocations and submissions (among other operations) gain a device mask that specifies which devices in the group participate in the operation. Our HAL already exposes queue affinity on most operations (though a few, such as events, need it added) for this purpose. This model matches what CUDA/HIP support for device peering and would allow us to build the compiler and produce programs in a way that works uniformly across them.
Device groups in Vulkan support a few extra things we may not use to start, such as the ability to mask commands within a command buffer to different device groups allowing for multi-device execution of single dispatches. To start command buffer granularity is probably fine as CUDA graphs and other APIs don't support this style of broadcasting.
Activity
Adding flag placeholders to semaphores/events. (#18122)