Skip to content

rocrtst: fix async-copy topology discovery under hwloc 2.x - #11137

Merged
amd-justchen merged 2 commits into
developfrom
users/shwetak/rocrtst-async-copy-hwloc-fix
Sep 3, 2026
Merged

amd-justchen merged 2 commits into
developfrom
users/shwetak/rocrtst-async-copy-hwloc-fix

Conversation

@shwetagkhatri

@shwetagkhatri shwetagkhatri commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

The rocrtstPerf.Memory_Async_Copy and Memory_Async_Copy_On_Engine performance
tests fail during topology discovery on systems that link a modern (hwloc 2.x)
NUMA library. The tests abort before running any bandwidth measurement and print
"**** No GPU found in same NUMA node as a CPU ****", which is misleading because
the real failure is that no PCI/IO devices were discovered at all.

Technical Details

Root cause is an hwloc header/library version mismatch. The tests compile against a
bundled hwloc 1.x header (thirdparty/include) but link a system hwloc 2.x library.

  • Under hwloc 1.x, IO/PCI devices are enabled with the topology flag
    HWLOC_TOPOLOGY_FLAG_IO_DEVICES.
  • Under hwloc 2.x that flag no longer enables IO devices; PCI/IO discovery is
    instead controlled by a type filter that defaults to KEEP_NONE. The old flag
    bit value additionally maps to a different (unrelated) flag in 2.x.

Consequently FindTopology() loads a topology with zero PCI devices,
hwloc_get_pcidev_by_busid() returns null for every GPU, and discovery aborts
with HSA_STATUS_ERROR before the NUMA comparison ever runs.

Fix (test-only, no runtime changes):

  1. memory_async_copy.cc FindTopology(): version-guard IO-device enablement.
    Keep HWLOC_TOPOLOGY_FLAG_IO_DEVICES for hwloc < 2.0; for hwloc >= 2.0 call
    hwloc_topology_set_io_types_filter(topology_, HWLOC_TYPE_FILTER_KEEP_ALL)
    before hwloc_topology_load().
  2. test_common/CMakeLists.txt: stop unconditionally putting the bundled
    thirdparty/include (hwloc 1.x header) on the global include path, so a
    system/TheRock hwloc 2.x build compiles against the matching 2.x header and the
    HWLOC_API_VERSION guards resolve correctly. The bundled header is added only
    inside the bundled-hwloc fallback branch.

Issue Tracking

JIRA ID : ROCM-29094

Test Plan

Built rocrtst against a system hwloc 2.7.0 library on a gfx942 (MI300A) host with
4 CPU NUMA nodes + 4 GPUs, then ran the affected filters:

./rocrtst64 --gtest_filter="*Memory_Async_Copy*"

Also confirmed via a standalone hwloc probe that with the fix the loaded topology
contains PCI objects (137) and every GPU busid resolves, versus zero PCI objects
and null lookups without it.

Test Result

  • Before fix: both tests abort with HSA_STATUS_ERROR (topology has 0 PCI devices).
  • After fix: Memory_Async_Copy PASSED and Memory_Async_Copy_On_Engine PASSED
    (full bandwidth run, ~163s each). 2/2 PASSED, no regressions.

Submission Checklist

Copilot AI lite review requested due to automatic review settings September 2, 2026 19:09
@therock-pr-bot

therock-pr-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

✅ All Policy Checks Passed

Check Status Details
📝 PR Description ✅ Pass —
⛔ Forbidden Files ✅ Pass —
🧪 Unit Test ⚠️ Warning Error: Source/code files changed without an accompanying unit test.
Expected: add at least one test file named like test_<name>.py / test_<name>.cpp (or <name>_test.*).
Current: code file(s) changed: projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc; no test file found
🚫 Draft PR 🔜 To Be Enabled —
🚩 Feature Flag 🔜 To Be Enabled —
📊 Code Coverage 🔜 To Be Enabled —

🎉 All policy checks passed!

📖 Need help? See the Policy FAQ for details on every check and how to fix failures.

🙋 Wish to Override Policy?

@therock-pr-bot

therock-pr-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🚫 Please fix the failed policies before requesting reviews.

The following policy checks failed:

  • ❌ PR Description

The Not ready to Review label has been added to this PR.
Once all policies pass, the label will be removed automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fallback hwloc header include path is currently added after the main rocrtst target is created, which can prevent the bundled header from being applied and break fallback builds.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates rocrtst’s async-copy performance tests and build logic to correctly discover PCI/IO devices when linking against hwloc 2.x, avoiding failures caused by hwloc header/library mismatches and ensuring topology discovery succeeds on modern systems.

Changes:

  • Version-guard hwloc IO-device enablement in MemoryAsyncCopy::FindTopology() (flags for hwloc < 2.0, IO type filter for hwloc >= 2.0).
  • Stop placing the bundled hwloc 1.x headers on the global include path; only use them in the bundled-hwloc fallback branch.
File summaries
File Description
projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt Prevents bundled hwloc 1.x headers from shadowing system/TheRock hwloc 2.x headers; scopes fallback header exposure.
projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc Enables PCI/IO discovery under hwloc 2.x via IO type filter while retaining hwloc 1.x behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cfreeamd cfreeamd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI-assisted pre-review (for @cfreeamd)

The hwloc 1.x/2.x migration in memory_async_copy.cc looks correct — gating HWLOC_TOPOLOGY_FLAG_IO_DEVICES to < 2.0 and using hwloc_topology_set_io_types_filter(KEEP_ALL) for 2.x is the right replacement, and the CMake change to stop the bundled 1.x header from shadowing a system 2.x lib (with the explanatory comment) is a good catch. Two non-blocking notes inline. Note: the missing-rocrtst-YAML check does not apply here — no new TEST()/TEST_P() entries were added, this only fixes existing discovery logic, so the config YAMLs need no update.

@shwetagkhatri
shwetagkhatri force-pushed the users/shwetak/rocrtst-async-copy-hwloc-fix branch from ec8e6af to 5279dff Compare September 2, 2026 21:02
@shwetagkhatri
shwetagkhatri requested review from cfreeamd and a lite review from Copilot September 2, 2026 21:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are narrowly scoped to test topology discovery, align with hwloc 1.x/2.x behavior, and the build-system adjustment correctly prevents header/library mismatches without impacting runtime code.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@shwetagkhatri

Copy link
Copy Markdown
Contributor Author

@cfreeamd @dayatsin-amd - Please help review this with priority. I have resolved earlier review comments. Thank you.

The Memory_Async_Copy performance tests compile against a bundled hwloc
1.x header while linking a system hwloc 2.x library. Under hwloc 2.x the
legacy HWLOC_TOPOLOGY_FLAG_IO_DEVICES flag has no effect; PCI/IO devices
are instead gated by a type filter that defaults to keeping none. As a
result the loaded topology contained no PCI devices, the busid lookup
returned null for every GPU, and topology discovery aborted with an error
before any bandwidth measurement ran.

Enable IO devices in a version-correct way: keep the legacy flag for
hwloc 1.x, and set the IO type filter to keep-all for hwloc 2.x. Also stop
forcing the bundled 1.x header onto the global include path so a system
hwloc 2.x build compiles against the matching 2.x header; the bundled
header is now used only in the bundled-library fallback.
…opagation

Check the return values of the hwloc IO-type-filter and topology-load calls in
the async-copy topology discovery path so a failure surfaces explicitly instead
of silently producing a topology with zero PCI devices.

Attach the bundled fallback hwloc header to the imported target's usage
requirements instead of a global include directory, so it propagates through
the link dependency independent of target/directory ordering.
@shwetagkhatri
shwetagkhatri force-pushed the users/shwetak/rocrtst-async-copy-hwloc-fix branch from 5279dff to 664bfc0 Compare September 3, 2026 01:45
@amd-justchen

Copy link
Copy Markdown
Contributor

Will merge given code owner approval.
The TheRock CI failures are only known infra issues, unrelated to the rocrtst async-copy hwloc topology fix:

  • Windows Build: build step cancelled (ninja interrupted); real failure at Configure AWS Credentials, an AWS OIDC token infra issue verified from the job log
  • MI455 hip-tests: known GPU out-of-memory infra, COMMON across unrelated PRs
  • Test rocprofiler-sdk (gfx94X): known infra test-timeout across unrelated PRs

@amd-justchen
amd-justchen merged commit aa24ea1 into develop Sep 3, 2026
29 of 38 checks passed
@amd-justchen
amd-justchen deleted the users/shwetak/rocrtst-async-copy-hwloc-fix branch September 3, 2026 22:41
systems-assistant Bot pushed a commit to ROCm/ROCR-Runtime that referenced this pull request Sep 3, 2026
The Memory_Async_Copy performance tests compile against a bundled hwloc
1.x header while linking a system hwloc 2.x library. Under hwloc 2.x the
legacy HWLOC_TOPOLOGY_FLAG_IO_DEVICES flag has no effect; PCI/IO devices
are instead gated by a type filter that defaults to keeping none. As a
result the loaded topology contained no PCI devices, the busid lookup
returned null for every GPU, and topology discovery aborted with an error
before any bandwidth measurement ran.

Enable IO devices in a version-correct way: keep the legacy flag for
hwloc 1.x, and set the IO type filter to keep-all for hwloc 2.x. Also stop
forcing the bundled 1.x header onto the global include path so a system
hwloc 2.x build compiles against the matching 2.x header; the bundled
header is now used only in the bundled-library fallback.
[rocm-systems] ROCm/rocm-systems#11137 (commit aa24ea1)
systems-assistant Bot pushed a commit to ROCm/ROCR-Runtime that referenced this pull request Sep 3, 2026
 header propagation

Check the return values of the hwloc IO-type-filter and topology-load calls in
the async-copy topology discovery path so a failure surfaces explicitly instead
of silently producing a topology with zero PCI devices.

Attach the bundled fallback hwloc header to the imported target's usage
requirements instead of a global include directory, so it propagates through
the link dependency independent of target/directory ordering.
[rocm-systems] ROCm/rocm-systems#11137 (commit aa24ea1)
@systems-assistant

Copy link
Copy Markdown
Contributor

TheRock Submodule Bump Activity

Newest first

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.

4 participants