Skip to content

[HAL] Fix host copies on non-coherent memory - #25342

Open
noahcoolboy wants to merge 1 commit into
iree-org:mainfrom
noahcoolboy:users/noahcoolboy/hal-noncoherent-host-copies
Open

noahcoolboy wants to merge 1 commit into
iree-org:mainfrom
noahcoolboy:users/noahcoolboy/hal-noncoherent-host-copies

Conversation

@noahcoolboy

Copy link
Copy Markdown

Several runtime helpers copy through host mappings without the cache maintenance that iree_hal_buffer_map_range requires for memory that is not IREE_HAL_MEMORY_TYPE_HOST_COHERENT:

  • iree_hal_buffer_map_read did not invalidate its source, unlike iree_hal_buffer_map_write, which flushes its target.
  • iree_hal_buffer_map_copy flushed its target but did not invalidate its source.
  • iree_hal_device_transfer_range did not invalidate a mappable source buffer before reading it.
  • iree_hal_buffer_view_generate_buffer did not flush after its callback wrote through the mapping.

The RapidCopySubmit CTS test wrote through a mapping without flushing, so it now flushes as the API requires.

Mesa's Vulkan driver for Intel GPUs (ANV) exposes host-visible memory that is cached but not coherent (DEVICE_LOCAL | HOST_VISIBLE | HOST_CACHED), and the Vulkan HAL allocator picks it for device-local, host-visible buffers. The GPUs in CI expose coherent host-visible memory, where these paths are no-ops, which is likely why this hasn't shown up there.

Tested on an Intel Arrow Lake-H iGPU (device 0x7dd1, Mesa 26.3, Linux 6.18)

Test Before After
CommandBufferCopyBufferTest.CopySubBuffer 3/3 failed pass
CommandBufferCopyBufferTest.CopyAlignedDisjointRangesWithinSameBuffer 3/3 failed pass
CommandBufferStressTest.RapidCopySubmit 3/3 failed pass
BdaRawSpirvReplayCacheTest.CommandBufferSkipsUnchangedBdaPublication 3/3 failed pass
DispatchReuseTest.MultiDispatchMultiResubmit (BDA) 13/50 failed 0/50
QueueTransferTest.ChainedFillCopyFill 5/50 failed 0/50

Assisted-by: Claude Code

Several runtime helpers copy through host mappings without the cache
maintenance that iree_hal_buffer_map_range requires for memory that is
not IREE_HAL_MEMORY_TYPE_HOST_COHERENT:

* iree_hal_buffer_map_read did not invalidate its source, unlike
  iree_hal_buffer_map_write, which flushes its target.
* iree_hal_buffer_map_copy flushed its target but did not invalidate
  its source.
* iree_hal_device_transfer_range did not invalidate a mappable source
  buffer before reading it.
* iree_hal_buffer_view_generate_buffer did not flush after its callback
  wrote through the mapping.

The RapidCopySubmit CTS test wrote through a mapping without flushing,
so it now flushes as the API requires.

Mesa's Vulkan driver for Intel GPUs (ANV) exposes host-visible memory
that is cached but not coherent, and the Vulkan HAL allocator picks it
for device-local, host-visible buffers. On an Arrow Lake iGPU, six
Vulkan CTS tests fail before this change (two intermittently) and pass
after it.

Assisted-by: Claude Code
Signed-off-by: noahcoolboy <46800081+noahcoolboy@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Hello @noahcoolboy 👋

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 policies

IREE 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:

  • Contributors must fully understand, and vouch for, all submitted changes and the intent behind them.
  • Substantial use of LLM/generative AI tools must be noted in the PR description, e.g. via Assisted-by: tool-name or Co-authored-by: tool-name tool@email trailers.
  • Contributors must write PR descriptions themselves. There must always be a human in the loop: contributors must respond to reviews and questions by themselves.
    If a response includes LLM-assisted segments (e.g. reproducers, LLM agent analysis excerpts), the segment should be clearly marked as "assisted", same as for PR contents.
  • GitHub issues labeled as "Good first issue" are explicitly designated as learning opportunities for newcomers to the project. With exceptions for boilerplate edits, AI tool usage for resolutions to such issues is forbidden.

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 guidance

Our 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.
In these cases, it should suffice to amend your commit signature(s) per the guide and force-push the PR branch.

If you have any questions, feel free to leave a comment here, or ask away on IREE Discord.

Thank you,
The IREE Community

@noahcoolboy

Copy link
Copy Markdown
Author

@github-actions I understand and accept

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant