Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "")
Expand Down Expand Up @@ -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)
Expand Down
Loading