Skip to content

[HAL/AMDGPU] Add execution-scoped virtual memory access - #367

Open
AWoloszyn wants to merge 2 commits into
mainfrom
users/awoloszyn/memory_access_Scope
Open

[HAL/AMDGPU] Add execution-scoped virtual memory access#367
AWoloszyn wants to merge 2 commits into
mainfrom
users/awoloszyn/memory_access_Scope

Conversation

@AWoloszyn

Copy link
Copy Markdown
Collaborator

Summary

Add portable host and device execution scopes to the HAL virtual-memory protection API and implement them in the
AMDGPU backend.

This enables callers to distinguish between memory accessible by device execution, host execution, or both. Queue
affinity continues to select the participating device topology, while the new access scope independently selects the
execution domains receiving access.

AMDGPU resolves these portable scopes to native agents internally. Native agent handles and access-policy details
remain private to the driver.

The change also improves host-memory imports by preserving both the original host address and the agent-visible
address when native registration produces different values.

Motivation

HIP virtual-memory APIs such as hipMemSetAccess require independent host and device access control. Queue affinity
alone cannot represent this distinction because host execution is not a device queue.

Handling this through an AMDGPU-private API would require HRX to identify the concrete backend and directly call
driver internals. That would break HAL encapsulation and would not work through allocator wrappers, proxies, or remote
execution.

The generic execution-scope contract preserves the requested policy through the HAL boundary while leaving each
backend responsible for translating or rejecting it.

Implementation

  • Add host, device, and combined virtual-memory access scopes to the HAL allocator API.
  • Forward the scope through caching, debugging, replay, and other allocator wrappers.
  • Have backends return IREE_STATUS_UNIMPLEMENTED when they cannot independently enforce a valid scope.
  • Resolve AMDGPU scopes to bounded, deduplicated native agent lists.
  • Keep native topology and agent handles internal to AMDGPU.
  • Preserve separate host and agent-visible addresses for imported host memory.
  • Remove the AMDGPU-private scoped-protection entry point.
  • Keep all topology resolution and native access updates off the dispatch hot path.

HIP functionality enabled

This supports the backend requirements for:

  • hipMemSetAccess and hipMemGetAccess
  • Host-only and device-only VMM permissions
  • Managed and registered host memory
  • Multi-device host-visible allocations
  • VMM-backed asynchronous allocation and memory pools

Translate logical-device affinity into bounded native agent sets for
allocation, host import, staging, and VMM protection. Preserve distinct
host and agent-visible addresses when imported fine-grained memory uses
different pointer representations.

Keep host-only and device-only VMM protection backend-specific because
generic queue affinity cannot represent those agent classes. These are
memory-management paths and add no work to ordinary dispatch.
Add portable host and device access scopes to virtual-memory
protection so allocator proxies and remote backends can preserve the
requested policy through the HAL vtable. Resolve those scopes to native
agents inside AMDGPU and keep backend allocation details private.
@AWoloszyn
AWoloszyn marked this pull request as ready for review August 13, 2026 14:37
@AWoloszyn
AWoloszyn requested a review from benvanik August 13, 2026 15:33
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