From 6614d8e5aa00275ee569a66fa31e1d155c97a64d Mon Sep 17 00:00:00 2001 From: Shweta Khatri <155576586+shwetagkhatri@users.noreply.github.com> Date: Wed, 2 Sep 2026 14:21:50 -0400 Subject: [PATCH 1/2] rocrtst: fix async-copy topology discovery under hwloc 2.x 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. --- .../suites/performance/memory_async_copy.cc | 15 +++++++++++++-- .../rocrtst/suites/test_common/CMakeLists.txt | 8 +++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc b/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc index 0e9bf6859c59..b48bef589773 100755 --- a/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc +++ b/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc @@ -900,8 +900,19 @@ static hsa_status_t GetAgentInfo(hsa_agent_t agent, void* data) { void MemoryAsyncCopy::FindTopology() { hsa_status_t err; - hwloc_topology_set_flags(topology_, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM | - HWLOC_TOPOLOGY_FLAG_IO_DEVICES); + hwloc_topology_set_flags(topology_, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM +#if HWLOC_API_VERSION < 0x00020000 + | HWLOC_TOPOLOGY_FLAG_IO_DEVICES +#endif + ); + + // hwloc 2.x removed the IO-device topology flags; PCI/IO devices are now + // controlled by a type filter that defaults to KEEP_NONE. Without this the + // topology contains no PCI devices and hwloc_get_pcidev_by_busid() below + // returns nullptr for every GPU, making topology discovery fail. +#if HWLOC_API_VERSION >= 0x00020000 + hwloc_topology_set_io_types_filter(topology_, HWLOC_TYPE_FILTER_KEEP_ALL); +#endif hwloc_topology_load(topology_); diff --git a/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt b/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt index 6e5ebb61bc8d..70d882c6a92b 100644 --- a/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt +++ b/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt @@ -463,7 +463,11 @@ set(ENABLE_COPY_NUMA_MEMBIND_NODESET OFF CACHE BOOL "Enable hwloc membind nodese include_directories(${ROCRTST_ROOT}) include_directories(${ROCRTST_ROOT}/gtest/include) -include_directories(${ROCRTST_ROOT}/thirdparty/include/) +# NOTE: ${ROCRTST_ROOT}/thirdparty/include holds a bundled hwloc 1.x header only. +# It must NOT be on the global include path when we link a system/TheRock hwloc +# 2.x library, otherwise the stale 1.x header shadows the 2.x one and enum/flag +# values (e.g. HWLOC_TOPOLOGY_FLAG_IO_DEVICES) silently mismatch the runtime lib. +# It is added below only in the bundled-hwloc fallback branch. # Custom command set for code objects. set (HSACO_TARG_LIST "") @@ -763,6 +767,8 @@ if(NOT HAVE_HWLOC) ) set(HWLOC_TARGET hwloc_imported) set(HAVE_HWLOC TRUE) + # The bundled thirdparty hwloc is 1.x; expose its matching header only here. + include_directories(${ROCRTST_ROOT}/thirdparty/include/) message(STATUS "Found hwloc library (fallback): ${HWLOC_LIBRARY}") message(WARNING "Using pre-built hwloc from thirdparty/lib - may have symbol version incompatibilities with TheRock's numa") else() From 664bfc01e199aa1bd259dcc1b17a7e64b824eff4 Mon Sep 17 00:00:00 2001 From: Shweta Khatri <155576586+shwetagkhatri@users.noreply.github.com> Date: Wed, 2 Sep 2026 16:10:10 -0400 Subject: [PATCH 2/2] rocrtst: harden hwloc topology discovery error handling and 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. --- .../rocrtst/suites/performance/memory_async_copy.cc | 10 ++++++++-- .../rocrtst/suites/test_common/CMakeLists.txt | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc b/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc index b48bef589773..d5057ef283df 100755 --- a/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc +++ b/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc @@ -911,10 +911,16 @@ void MemoryAsyncCopy::FindTopology() { // topology contains no PCI devices and hwloc_get_pcidev_by_busid() below // returns nullptr for every GPU, making topology discovery fail. #if HWLOC_API_VERSION >= 0x00020000 - hwloc_topology_set_io_types_filter(topology_, HWLOC_TYPE_FILTER_KEEP_ALL); + int io_filter_err = + hwloc_topology_set_io_types_filter(topology_, HWLOC_TYPE_FILTER_KEEP_ALL); + ASSERT_EQ(0, io_filter_err) + << "hwloc_topology_set_io_types_filter() failed; PCI/IO devices will not " + "be discovered and GPU-to-NUMA topology matching cannot succeed."; #endif - hwloc_topology_load(topology_); + int topo_load_err = hwloc_topology_load(topology_); + ASSERT_EQ(0, topo_load_err) + << "hwloc_topology_load() failed; topology is unusable."; err = hsa_iterate_agents(GetAgentInfo, this); diff --git a/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt b/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt index 70d882c6a92b..30ecf6ca1361 100644 --- a/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt +++ b/projects/rocr-runtime/rocrtst/suites/test_common/CMakeLists.txt @@ -762,13 +762,16 @@ if(NOT HAVE_HWLOC) if(HWLOC_LIBRARY) add_library(hwloc_imported SHARED IMPORTED) + # The bundled thirdparty hwloc is 1.x; expose its matching header through the + # imported target's usage requirements so it propagates via + # target_link_libraries(${ROCRTST} ${HWLOC_TARGET}) below, independent of + # directory/target ordering (and without a global include_directories()). set_target_properties(hwloc_imported PROPERTIES IMPORTED_LOCATION "${HWLOC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${ROCRTST_ROOT}/thirdparty/include" ) set(HWLOC_TARGET hwloc_imported) set(HAVE_HWLOC TRUE) - # The bundled thirdparty hwloc is 1.x; expose its matching header only here. - include_directories(${ROCRTST_ROOT}/thirdparty/include/) message(STATUS "Found hwloc library (fallback): ${HWLOC_LIBRARY}") message(WARNING "Using pre-built hwloc from thirdparty/lib - may have symbol version incompatibilities with TheRock's numa") else()