Repository navigation
fix(rocr,clr): refresh owning agent for dmabuf-imported VMM handles - #14279
AidanBeltonS wants to merge 14 commits into
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
There was a problem hiding this comment.
🟡 Changes recommended
Copy and fill paths can select a GPU without mapping access, and the ownership test fails with the supported rollback flag disabled.
2 open issues
What changed in this PR
This PR aims to restore memcpy-batch throughput by reporting recoverable imported-memory ownership in ROCr and refreshing CLR’s cached owning agents after mapping.
Changes:
- Report exporting GPU ownership for supported DMA-buffer imports, with a rollback flag.
- Centralize CLR’s post-map ownership refresh behind a separate flag.
- Extend imported-memory pointer-info tests and add safeguards for missing owners.
| File | Description |
|---|---|
projects/rocr-runtime/runtime/hsa-runtime/core/util/flag.h |
Add the imported-owner reporting flag. |
projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp |
Recover imported ownership and handle missing owners. |
projects/rocr-runtime/rocrtst/suites/functional/virtual_memory.h |
Declare the host-backed import test. |
projects/rocr-runtime/rocrtst/suites/functional/virtual_memory.cc |
Check ownership for GPU, fabric, and host-backed imports. |
projects/clr/rocclr/utils/flags.hpp |
Add the ownership-refresh flag. |
projects/clr/rocclr/device/rocm/rocvirtual.cpp |
Delegate ownership refresh to shared map bookkeeping. |
projects/clr/rocclr/device/rocm/rocmemory.cpp |
Preserve cached ownership when queries cannot resolve it. |
projects/clr/rocclr/device/rocm/rocdevice.hpp |
Declare the ROCm ownership-refresh override. |
projects/clr/rocclr/device/rocm/rocdevice.cpp |
Refresh ownership on existing context-device views and the dispatching device. |
projects/clr/rocclr/device/device.hpp |
Add a backend ownership-refresh hook. |
projects/clr/rocclr/device/device.cpp |
Invoke the hook after map bookkeeping. |
Review effort: Balanced
cfreeamd
left a comment
There was a problem hiding this comment.
🤖 AI-assisted pre-review (for @cfreeamd) — [CLR][ROCr-Runtime] Import owning agent correctly for memcpy-batch async
The ROCr-side defensive fixes in FillMemory, CopyMemory, and IPCCreate all guard real null-deref paths (importing memory can now yield agentOwner.handle == 0, and Agent::Convert(hsa_agent_t{0}) is a null pointer). The CLR RefreshMappedMemoryOwner override and the post-map ownership refresh logic in rocmemory.cpp look structurally sound. The VMemoryPtrInfo guard for imported handles (memHandle->region != nullptr checked before agentOwner()) reads correctly — memRegion is set to nullptr for imported handles so the old code path does not run for them. The auto-scanner's rocrtst_yaml_missing flag is a false positive here: HostBackedImportedHandlePointerInfo is a new private method called from the existing TestImportedHandlePointerInfo orchestrator — no new TEST()/TEST_P() macro registration.
[Required] PR title [CLR][ROCr-Runtime] Import owning agent correctly for memcpy-batch async does not follow the required type(component): format (ROCm squash-merges, so this becomes the permanent commit title). Suggested: fix(rocr): refresh owning agent for dmabuf-imported VMM handles
cfreeamd
left a comment
There was a problem hiding this comment.
🤖 AI-assisted pre-review (for @cfreeamd) — follow-up after author update
Two prior questions addressed: EnsureImportInfo is now called in VMemoryHandleMap (gated by enable_vmem_import_owner()), and the early-return in refreshOwningAgentFromPointerInfo is documented as intentional (keeps create()-time agent on failure/zero-handle). The access-restriction safety question on VMemoryPtrInfo remains open (see inline). Title format (type(component):) is still required.
Nits in new code (commit 2): resport → report in HostBackedImportedHandlePointerInfo banner; independant → independent in VmemImportResolvedAgent comment.
|
🤖 AI-assisted pre-review (for @mangupta) Re-reviewed the updated head ( |
cfreeamd
left a comment
There was a problem hiding this comment.
🤖 AI-assisted pre-review (for @cfreeamd) — follow-up after author update
Prior access-restriction safety concern resolved: OwnerCanBlit correctly gates blit dispatch on VA accessibility for both CopyMemory and FillMemory. Test rollback-mode fix (VmemImportOwnerEnabled()) is clean. Two new [Important] issues in the newly-added test registration (VirtMemory_Imported_Blit_Without_Owner_Access_Test) — see inline comments.
Also: PR title is now fix(rocr, clr): which is a clear improvement from the original but the comma-scoped form is still flagged as non-conforming; fix(rocr): (primary touched component) would satisfy the checker.
vmmOwningAgent() and hsa_amd_pointer_info reach the same field in ROCr: both read the imported MemoryHandle's resolved region owner, populated by the same EnsureImportInfo() call. Keeping both left two doors to retrieving the same value.
fc84a3d to
c03c7b9
Compare
cfreeamd
left a comment
There was a problem hiding this comment.
🤖 AI-assisted pre-review (for @cfreeamd) — follow-up after latest commits
Latest commit (cfab862) adds to — the [Important] YAML gap is resolved.
On the rebuttal: accepted. The pattern honors the skip verdict via the return value; the broken pattern was calling it without checking. Retracting the [Important] finding on that.
Remaining before merge:
- [Required] PR title — comma-scoped form still non-conforming; suggest .
- [Nit] Typos and in virtual_memory.cc still present.
- dayatsin has two open threads that need an author response: (1) simplification, (2) whether should be made permanently-on.
|
🤖 AI-assisted pre-review (for @mangupta) Re-reviewed the updated head ( |
Query the dmabuf while constructing MemoryHandle from the fd, under the caller's memory lock, and drop the lazy EnsureImportInfo cache. Imported handles then carry their region before map and handle queries. JIRA ID : ROCM-33394 Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the dmabuf constructor query and restore FindDriverMemoryHandle, CopyMemory, FillMemory, VMemoryPtrInfo, and IPCCreate to their previous behavior. JIRA ID : ROCM-33394 Co-authored-by: Cursor <cursoragent@cursor.com>
|
🤖 AI-assisted pre-review (for @mangupta) Re-reviewed the updated head ( |
|
🤖 AI-assisted pre-review (for @mangupta) Re-reviewed the updated head ( |


Motivation
RCCL has seen a significant performance regression in throughput bound operations with memcpy-batch. This is due to the copy engine not being selected when performing the operation. This PR aims to regain the lost performance
Technical Details
Performance: 8 GPU memcpy-batch async benchmark: Develop 21588.01us vs VMM-import branch 10954.91 us. This is a toy benchmark so the exact change seen in RCCL should take this into consideration. I am able to provide further performance results offline
To allow quick testing of this features performance and potential bugs they are both guarded with flags.
ROCR changes are guarded with flag:
HSA_ENABLE_VMEM_IMPORT_OWNERCLR changes are guarded with flag:
ROC_VMM_REFRESH_OWNING_AGENTIssue Tracking
JIRA ID: ROCM-33394
Submission Checklist