Repository navigation
[HAL] Add command buffer flush and invalidate operations - #24945
Conversation
|
Hello @purnima-nlp 👋 Thank you for submitting a Pull Request to IREE! It looks like this is your first one. We have one ask, and you can also find some general tips below. Action required: acknowledge IREE project policiesIREE is a Linux Foundation project. All participants are expected to follow the LF Projects Code of Conduct. All contributions to IREE must follow our IREE AI Tool Use Policy. In particular:
We kindly ask you to reply to this message and confirm that you understand and accept the cited policies, particularly the AI Tool Use Policy. General guidanceOur general Contributing guide contains information and links to detailed guides on code quality, testing, commit summaries and our CI system. A common point for new PRs: if a DCO signing check fails for you, check out the section on Developer Certificate of Origin. If you have any questions, feel free to leave a comment here, or ask away on IREE Discord. Thank you, |
|
@purnima-nlp could you take a moment to read & acknowledge the policies? |
I understand and accept the cited policies |
Manewing
left a comment
There was a problem hiding this comment.
Looks good so far :) just a few comments
Also, could we add a few runtime tests for the inline and deferred implementations? A mock buffer that tracks flush/invalidate calls should let us check that the calls happen at the right time, receive the correct ranges, and propagate errors. It would also be good to cover missing indirect bindings and the UNIMPLEMENTED fallback. None of that should require support in the other backends.
For copy buffer there already is some test setup in runtime/src/iree/hal/cts/command_buffer/copy_buffer_test.cc I think we can implement the tests in a similar fashion for flush/invalidate
|
@Manewing Thanks for the review comments — I’ve started addressing them in focused parts. So far I’ve updated the generic command-buffer APIs to add validation, replaced the ternary dispatch with explicit handling, added the backend-support FIXME, and clarified the flush/invalidate docs to state that they perform cache maintenance but do not establish execution dependencies. For the tests, I’m splitting the work like below:
The generic API tests are now in place and passing. They cover exact buffer-ref forwarding, callback error propagation, zero-length no-op behavior, missing backend callbacks returning Next I’m adding the inline and deferred tests, including timing/range behavior, indirect bindings, and error propagation as you suggested. |
There was a problem hiding this comment.
LGTM, @purnima-nlp. Linting & DCO issues need to be resolved.
fedad1b to
dde0824
Compare
Manewing
left a comment
There was a problem hiding this comment.
Thanks for adding the test cases!
Two things before this can merge:
- The CI issues need to be addressed
- I think there is a an issue with current validation. Both new validators leave
target_reqs.usageat zero, butiree_hal_command_buffer_validate_binding_requirementstreats that as an unused binding and returns immediately. This skips the required-buffer, memory-type, and range checks. Could we ensure flush/invalidate bindings are treated as required and add validation-enabled tests for null and undersized bindings? The null binding could reach inline replay and cause an assertion/null dereference.
dde0824 to
4710eee
Compare
Thanks! I’ve addressed both points:
I also fixed the clang-format CI issue locally using the repo’s pre-commit hook. The focused runtime tests are passing: 13 command buffer + 10 inline + 10 deferred tests. I’ve pushed the updated commit and CI is rerunning now. |
4710eee to
3ee39f5
Compare
|
I’ve pushed a small follow-up fix for the Windows MSVC C++17 build failure. The new workflow run is waiting for approval since the PR is from a fork. Could someone please approve the workflow run when convenient? |
Signed-off-by: purnima <[email protected]>
3ee39f5 to
83b9596
Compare
|
The checks that didn't pass are unrelated to this PR |
This PR adds HAL and runtime plumbing for ordered command-buffer buffer flush and invalidate operations.
It introduces:
hal.command_buffer.flush_bufferhal.command_buffer.invalidate_bufferThe operations carry a buffer reference, offset, and length and are intended to represent execution-ordered cache maintenance for shared non-coherent memory.
Stream-to-HAL lowering is intentionally left unchanged in this PR. Some backends, especially Vulkan, require queue/submission-level handling to preserve execution-time ordering because a HAL command buffer is currently replayed into a single native
VkCommandBuffer. Enabling Stream lowering before that backend support exists could cause unsupported runtime paths.This PR therefore focuses on establishing the HAL/runtime infrastructure first. Backend-specific execution support and Stream lowering can follow separately.
Related to #24930.
AI Tool Disclosure
Assisted by codex for code base exploration