feat(vmm): host-NUMA support for hipMemCreate — coverage experiment (clone of ROCm#8058)#2
Open
jainprad wants to merge 5 commits into
Open
feat(vmm): host-NUMA support for hipMemCreate — coverage experiment (clone of ROCm#8058)#2jainprad wants to merge 5 commits into
jainprad wants to merge 5 commits into
Conversation
Add HIP virtual-memory support for hipMemLocationTypeHostNuma and hipMemLocationTypeHostNumaCurrent, backed by host-resident CPU NUMA pools. - hip_vm.cpp: accept the two NUMA location types in hipMemCreate / hipMemGetAllocationGranularity / hipMemSetAccess; validate location.id as a NUMA node id (not a device index) for HostNuma; pack node selector into the upper 32 bits of the 64-bit alloc flags; resolve owning device for VA ops via VmmOwnerDeviceIndex so host allocs don't index g_devices with a node id. - ROCclr: extend VmmLocationType with kHostNuma/kHostNumaCurrent (parity with hipMemLocationType, static_assert'd); thread numaNode through SetMemAccess and resolve the per-node CPU agent; add Device::hostVmemAlloc (CPU-pool VMM alloc) + Device::hostVmemSupported capability guard (HSA_AMD_AGENT_INFO_HOST_ALLOC_ DMABUF_SUPPORTED); add numHostNumaNodes(); route PHYMEM allocation to hostVmemAlloc for the NUMA types only (Host unchanged). - PAL: keep SetMemAccess signature compiling (host-NUMA unsupported). - tests: add hipMemCreateHostNuma.cc (granularity, alloc/dealloc, memcpy roundtrip, kernel launch, negatives, placement) + libnuma wiring + YAML tags. 5/6 tests pass; placement node-residency check is WIP (move_pages/get_mempolicy do not introspect dma-buf-backed VMM mappings). test(vmm): replace host-NUMA placement check with host+device access test The dma-buf/GTT-backed VMM mapping is not a normal anonymous VMA, so userspace NUMA introspection (move_pages/get_mempolicy/numa_maps) cannot resolve its node (verified: move_pages -> EFAULT, get_mempolicy -> EFAULT, VA absent from /proc/self/numa_maps). NUMA node selection is a code-level guarantee in ROCclr's hostVmemAlloc (picks cpu_agents_[node]'s pool); asserting it from userspace would need root-only KFD topology. Replace Unit_hipMemCreate_HostNuma_Placement with Unit_hipMemCreate_HostNuma_HostAndDeviceAccess, which verifies the meaningful, testable property: the allocation is host-resident and CPU-accessible (CPU writes -> GPU squares in place -> CPU reads results) across HostNuma and HostNumaCurrent. All 6 host-NUMA cases pass. Co-Authored-By: Claude <noreply@anthropic.com> (cherry picked from commit 9455dca)
(cherry picked from commit 961d044)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> (cherry picked from commit 8b40bb3)
CI runs under cpuset-partitioned containers (Kubernetes/Docker slices) where the process is restricted to a subset of the machine's NUMA nodes. numa_max_node() reports hardware nodes regardless of the cpuset, so the tests could request a HostNuma allocation on a node the process isn't permitted to use. That returns a mapping whose pages cannot be faulted in, and the direct CPU write in HostAndDeviceAccess / NumaTypedAccess crashes with SIGBUS. Add allowedNumaNodes() (numa_get_mems_allowed) and drive node selection from the allowed set instead of numa_max_node(); skip when the allowed set is empty. The negative test keeps using numa_max_node()+1 for its out-of-range id since that check validates against the hardware CPU-agent count, not the cpuset. Co-Authored-By: Claude <noreply@anthropic.com> (cherry picked from commit 32f7b7b)
Add this PR's own coverage gate so PR ROCm#8058-clone is measured on its own changed lines, independently of any other PR: - ci/coverage/build_and_test.sh, collect_and_gate.sh, README.md - .github/workflows/pr-diff-coverage.yml (runs on projects/clr/** PRs; emits coverage.html + diff-coverage.html artifact, gates diff coverage) Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clone of upstream ROCm/rocm-systems#8058 (by @cjatin) for a code-coverage experiment. The upstream PR is left untouched — this is a copy of its 4 commits (
git cherry-pick -x) onto this fork'sdevelop.Host-NUMA support for
hipMemCreate(hipMemLocationTypeHostNuma/HostNumaCurrent), backed by host-resident CPU NUMA pools in ROCclr, plus a new unit testhipMemCreateHostNuma.cc.Purpose of this fork PR
Run the PR's newly added tests (and related existing VMM tests) against a coverage-instrumented
libamdhip64.soand report diff/patch coverage of the PR's changed lines (the Phase 1 gate).Changed files (same as ROCm#8058)
hip_vm.cpp/.hpp,rocclr/device/{device.hpp, rocm/rocdevice.*, rocm/rocmemory.cpp, pal/paldevice.*},platform/memory.hppvirtualMemoryManagement/hipMemCreateHostNuma.cc(new),FindNUMA.cmake,CMakeLists.txt,virtualMemoryManagement.yamlTest plan
--coverage+ PR code on a ROCm-compatible base.hipMemCreateHostNumatest (and existing VMM tests) on GPU.Made with Cursor