Repository navigation
Adding skeleton AMDGPU buffer handle and handle pool. - #21044
Conversation
0e3a533 to
fd8e95f
Compare
57a0d9b to
f3b3161
Compare
fd8e95f to
f239530
Compare
f3b3161 to
1217491
Compare
7f6f67e to
4a20958
Compare
| // Topology with all CPU and GPU agents. Buffers must be visible to all. | ||
| const iree_hal_amdgpu_topology_t* topology; |
There was a problem hiding this comment.
Out of curiosity, can the topology change while the program is running, e.g. from a new GPU being connected or a previously hidden device being made available? Would that trigger a device loss or some other error that the application or IREE runtime libraries would listen for and respond to?
I get the impression that HSA is low enough level that such events could happen... like on a laptop with multiple accelerators or some platform with hot swappable devices.
There was a problem hiding this comment.
Conceptually yeah, but I don't think so in practice. I love the idea though :)
I think everything assumes it is all handled by automatic driver-level power island magic instead: you can always create a device and have it live but if you don't do anything with it for awhile it'll power down/go idle, and then when you go to use it again it comes back. Hot swap is a process restart kind of thing. ROCR itself caches a bunch of things at library load time and never re-queries (and thus HIP & co do the same), so we'll be limited by that even if we did want to do something cooler. A hosting application could be a bit more dynamic by reinitializing IREE if there was a significant event where they wanted to switch the active device set, so long as the underlying layers were fixed to be more dynamic.
The driver will implement two buffer types to start (or more?): `iree_hal_amdgpu_external_buffer_t` and `iree_hal_amdgpu_transient_buffer_t`. The external buffer will be used for imported buffers and synchronous allocations (probably), while the transient buffer is used for all asynchronous allocations. The transient buffer maintains a reference to a device-accessible `iree_hal_amdgpu_device_allocation_handle_t` that stores the allocated pointer. The device-side allocator will update the handle as it allocates/deallocates and anyone resolving buffer pointers (e.g. `iree_hal_amdgpu_device_buffer_ref_resolve`) fetches the current pointer from the handle. The pointer is only valid between alloca/dealloca ops (which will set/reset the pointer). `iree_hal_amdgpu_device_buffer_ref_t` is a variant that allows binding tables and command buffer ops to reference typed buffers. Most code can dereference device pointers (synchronously allocated buffers, imported buffers, etc) and the transient buffer handles. Command buffers can reference binding table slots with a relative offset/length. `iree_hal_amdgpu_device_workgroup_count_buffer_ref_t` is a special case for indirect dispatches (where the length is always known) as it packs better into space-constrained structs. A simple `iree_hal_amdgpu_buffer_pool_t` handles both the host `iree_hal_buffer_t` instances and device allocation handles. The device allocation handles can be stored in device memory to avoid additional bus traffic on each dereference. In the steady state of invocations with alloca/dealloca the pool should remove all host/device allocations.
The driver will implement two buffer types to start (or more?):
iree_hal_amdgpu_external_buffer_tandiree_hal_amdgpu_transient_buffer_t. The external buffer will be used for imported buffers and synchronous allocations (probably), while the transient buffer is used for all asynchronous allocations. The transient buffer maintains a reference to a device-accessibleiree_hal_amdgpu_device_allocation_handle_tthat stores the allocated pointer. The device-side allocator will update the handle as it allocates/deallocates and anyone resolving buffer pointers (e.g.iree_hal_amdgpu_device_buffer_ref_resolve) fetches the current pointer from the handle. The pointer is only valid between alloca/dealloca ops (which will set/reset the pointer).iree_hal_amdgpu_device_buffer_ref_tis a variant that allows binding tables and command buffer ops to reference typed buffers. Most code can dereference device pointers (synchronously allocated buffers, imported buffers, etc) and the transient buffer handles. Command buffers can reference binding table slots with a relative offset/length.iree_hal_amdgpu_device_workgroup_count_buffer_ref_tis a special case for indirect dispatches (where the length is always known) as it packs better into space-constrained structs.A simple
iree_hal_amdgpu_buffer_pool_thandles both the hostiree_hal_buffer_tinstances and device allocation handles. The device allocation handles can be stored in device memory to avoid additional bus traffic on each dereference. In the steady state of invocations with alloca/dealloca the pool should remove all host/device allocations.