Skip to content

feat(vmm): host-NUMA support for hipMemCreate — coverage experiment (clone of ROCm#8058)#2

Open
jainprad wants to merge 5 commits into
developfrom
jainprad/numa-support-coverage
Open

feat(vmm): host-NUMA support for hipMemCreate — coverage experiment (clone of ROCm#8058)#2
jainprad wants to merge 5 commits into
developfrom
jainprad/numa-support-coverage

Conversation

@jainprad

@jainprad jainprad commented Jul 7, 2026

Copy link
Copy Markdown
Owner

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's develop.

Host-NUMA support for hipMemCreate (hipMemLocationTypeHostNuma / HostNumaCurrent), backed by host-resident CPU NUMA pools in ROCclr, plus a new unit test hipMemCreateHostNuma.cc.

Purpose of this fork PR

Run the PR's newly added tests (and related existing VMM tests) against a coverage-instrumented libamdhip64.so and report diff/patch coverage of the PR's changed lines (the Phase 1 gate).

Changed files (same as ROCm#8058)

  • Runtime: hip_vm.cpp/.hpp, rocclr/device/{device.hpp, rocm/rocdevice.*, rocm/rocmemory.cpp, pal/paldevice.*}, platform/memory.hpp
  • Tests: virtualMemoryManagement/hipMemCreateHostNuma.cc (new), FindNUMA.cmake, CMakeLists.txt, virtualMemoryManagement.yaml

Test plan

Made with Cursor

cjatin and others added 4 commits July 7, 2026 10:24
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants