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..d5057ef283df 100755 --- a/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc +++ b/projects/rocr-runtime/rocrtst/suites/performance/memory_async_copy.cc @@ -900,10 +900,27 @@ 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_load(topology_); + 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 + 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 + + 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 6e5ebb61bc8d..30ecf6ca1361 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 "") @@ -758,8 +762,13 @@ 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)