Skip to content

Adding inline command buffers to the HAL API and a basic implementation. - #5508

Merged
benvanik merged 2 commits into
mainfrom
benvanik-inline-cmd-buf
Apr 20, 2021
Merged

benvanik merged 2 commits into
mainfrom
benvanik-inline-cmd-buf

Conversation

@benvanik

@benvanik benvanik commented Apr 18, 2021 •

Copy link
Copy Markdown
Collaborator

Adds the IREE_HAL_COMMAND_BUFFER_MODE_ALLOW_INLINE_EXECUTION mode to the HAL API.
This information can be useful for just about any backend (not just local single-threaded CPU) and it's carefully defined here to allow us to use it in remote/sandbox, async accelerator, and the task system backends as well. The intent is that future compiler passes that introduce asynchronous overlapping execution will be optional and when disabled all command buffers can carry this flag (or have an alternate code path generated for them).

To test this I've added iree_hal_inline_command_buffer_t - a simple command buffer that just executes as it records and does not persist the recorded commands. This can be used for one-shot primary command buffers in the task system when we start to use secondary command buffers to contain the bulk of the dispatches and for the synchronous HAL.

This is only part of what's required for a full non-task-system synchronous backend: command buffer recording and reuse will be an important performance feature and we'll want to allow it (if not require it) even on systems where we would use this. In such cases the inline execution will be used for the primary dynamic command buffers and they may execute reusable secondary command buffers.

To test this I hacked it into the task backend to create this hilarious trace:
image

Progress on #4680.

@benvanik benvanik added performance ⚡ Performance/optimization related work across the compiler and runtime hal/cpu Runtime Host/CPU-based HAL backend labels Apr 18, 2021
@google-cla google-cla Bot added the cla: yes label Apr 18, 2021
@benvanik
benvanik requested a review from ScottTodd April 18, 2021 22:50
@benvanik
benvanik force-pushed the benvanik-inline-cmd-buf branch from 026603c to b2f34a3 Compare April 18, 2021 23:11
@benvanik
benvanik force-pushed the benvanik-hal-submit-and-wait branch from 6861032 to 4d25359 Compare April 19, 2021 17:19
Base automatically changed from benvanik-hal-submit-and-wait to main April 19, 2021 17:57
This will allow us to implement synchronous execution behavior for local
execution.
Comment thread iree/hal/command_buffer.c Resolved
Comment thread iree/hal/command_buffer.h Resolved
Comment thread iree/hal/device.c Resolved
Comment thread iree/hal/local/local_executable.c Resolved
Comment thread iree/hal/local/inline_command_buffer.h Resolved
This is a command buffer that can be used for _ALLOW_INLINE_EXECUTION mode
command buffers when no threading is desired.

Future improvements could make the actual dispatch pluggable such that
it could be used with the task system, another thread pool, etc. For now
all dispatches execute synchronously on the recording thread.
@benvanik
benvanik force-pushed the benvanik-inline-cmd-buf branch from b2f34a3 to a01e9ff Compare April 19, 2021 18:32
@benvanik
benvanik requested a review from ScottTodd April 19, 2021 18:33
@benvanik
benvanik merged commit 4347593 into main Apr 20, 2021
@benvanik
benvanik deleted the benvanik-inline-cmd-buf branch April 20, 2021 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hal/cpu Runtime Host/CPU-based HAL backend performance ⚡ Performance/optimization related work across the compiler and runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants