Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0e5b9f4
UCS/TOPO: Initial topo groups infrastructure
guy-ealey-morag Aug 19, 2026
e21dd8a
UCS/TOPO: Change include path to absolute
guy-ealey-morag Aug 19, 2026
0c9b8ad
UCS/TOPO: Change nics in groups to be under boards
guy-ealey-morag Aug 19, 2026
424f2d2
UCS/TOPO: Build VR device inventory in preparation for grouping
guy-ealey-morag Aug 19, 2026
cbd7dfa
UCS/TOPO: Fix docs
guy-ealey-morag Aug 19, 2026
41c7ade
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 19, 2026
57bd182
UCS/TOPO/VR: Add fw_ver reading
guy-ealey-morag Aug 20, 2026
d2a186d
UCS/TOPO: Update groups types to use sized arrays
guy-ealey-morag Aug 20, 2026
43544e8
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 20, 2026
8ec91cd
UCS/TOPO: Move VR files into its own folder
guy-ealey-morag Aug 20, 2026
851958e
UCS/TOPO: Move VR files into its own folder
guy-ealey-morag Aug 20, 2026
76366e8
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 20, 2026
ace0d12
UCS/TOPO: Rename ucs_topo_gpu_t
guy-ealey-morag Aug 21, 2026
e53e42c
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 21, 2026
f44a84f
UCS/TOPO: Fix typo
guy-ealey-morag Aug 24, 2026
5493800
UCS/TOPO: Reorganize topo groups file and api
guy-ealey-morag Aug 24, 2026
a428a81
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 24, 2026
8800dbd
UCS/TOPO: Refactor groups inventory
guy-ealey-morag Aug 24, 2026
fbb6c3c
UCS/TOPO: Add todo
guy-ealey-morag Aug 24, 2026
ad06365
UCS/TOPO: Collect physical gpus and nic in inventory
guy-ealey-morag Aug 24, 2026
2e64a83
UCS/TOPO: Use ucs_array for nics and gpus, remove boards
guy-ealey-morag Aug 24, 2026
b5295f0
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 24, 2026
c165b6b
UCS/TOPO: Use ucs arrays
guy-ealey-morag Aug 24, 2026
defab99
UCS/TOPO: Use ucs_array for nics and gpus, remove boards
guy-ealey-morag Aug 24, 2026
37644d6
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 24, 2026
bb0864b
UCS/TOPO: Inventory cleanup
guy-ealey-morag Aug 24, 2026
bf8a946
UCS/TOPO: Move declarations to topo_groups.h
guy-ealey-morag Aug 24, 2026
01680f3
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 24, 2026
5a6bbb4
UCS/TOPO: Add missing doc
guy-ealey-morag Aug 24, 2026
615a075
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 24, 2026
11ec84c
UCS/TOPO: Rename init to build
guy-ealey-morag Aug 24, 2026
26b23e5
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 24, 2026
e841f67
UCS/TOPO: Init groups before return
guy-ealey-morag Aug 24, 2026
7712e2f
UCS/TOPO: Use array for each
guy-ealey-morag Aug 25, 2026
b8c3681
Merge branch 'master' into topo-groups-initial
guy-ealey-morag Aug 27, 2026
7abeb61
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 27, 2026
76fc542
UCS/TOPO: Use device's pci_id attr
guy-ealey-morag Aug 27, 2026
9036f03
UCS/TOPO: Remove unused include
guy-ealey-morag Aug 27, 2026
474ca21
Merge branch 'master' into topo-groups-initial
guy-ealey-morag Aug 28, 2026
e8c5650
Merge branch 'topo-groups-initial' into vr-build-inventory
guy-ealey-morag Aug 28, 2026
4e72f2a
Merge branch 'master' into topo-build-inventory
guy-ealey-morag Sep 1, 2026
ae53143
UCS/TOPO: Fix build errors after merge
guy-ealey-morag Sep 1, 2026
5ce1fca
UCS/TOPO: Add asserts
guy-ealey-morag Sep 1, 2026
f462319
UCS/TOPO: Fix coverty issue
guy-ealey-morag Sep 1, 2026
db4b326
UCS/TOPO: PR comments fixes
guy-ealey-morag Sep 8, 2026
4f362eb
UCP/TOPO: Unify sys dev compare logic
guy-ealey-morag Sep 8, 2026
cf07023
Merge branch 'master' into topo-build-inventory
guy-ealey-morag Sep 8, 2026
1ffc5f3
UCS/TOPO: Minor fixes
guy-ealey-morag Sep 8, 2026
2fa6f80
UCS/TOPO: Add comment about CX9 fw ver
guy-ealey-morag Sep 8, 2026
0503e2e
UCS/TOPO: PR comments fixes
guy-ealey-morag Sep 9, 2026
6ede74a
UCS/TOPO: PR comments fixes
guy-ealey-morag Sep 9, 2026
6101659
UCS/TOPO: Merge group_nic and group_gpu into group_element
guy-ealey-morag Sep 9, 2026
11d1227
UCS/TOPO: Fix PR comments
guy-ealey-morag Sep 9, 2026
cfc44cf
UCS/TOPO: rename devices to sys_devs
guy-ealey-morag Sep 9, 2026
f2eafa6
UCS/TOPO: Fix device_class check
guy-ealey-morag Sep 9, 2026
6f22749
UCS/TOPO: Refactor ucs_topo_groups_nics_cx9_filter
guy-ealey-morag Sep 9, 2026
a7eb44e
UCS/TOPO: Remove groups type
guy-ealey-morag Sep 9, 2026
05c3e35
UCS/TOPO: PR comment fix
guy-ealey-morag Sep 9, 2026
defdf86
UCS/TOPO: Simplify indention
guy-ealey-morag Sep 9, 2026
c020a4b
UCS/TOPO: PR comments fix
guy-ealey-morag Sep 9, 2026
0fbc99d
UCS/TOPO: Minor rename
guy-ealey-morag Sep 9, 2026
33a2ba7
UCS/TOPO: PR comment fix
guy-ealey-morag Sep 9, 2026
dcd7127
UCS/TOPO: PR comments fix
guy-ealey-morag Sep 10, 2026
cab9de0
UCS/TOPO: PR comments fix
guy-ealey-morag Sep 10, 2026
7a2e3ff
UCS/TOPO: Fix reason type
guy-ealey-morag Sep 10, 2026
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
30 changes: 3 additions & 27 deletions src/ucp/proto/proto_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,13 @@ ucp_proto_multi_get_avail_bw(const ucp_proto_init_params_t *params,
return lane_perf->bandwidth * ratio;
}

static ucs_bus_id_bit_rep_t
ucp_proto_multi_sys_dev_bus_id_key(ucs_sys_device_t sys_dev)
{
ucs_sys_bus_id_t bus_id;

if (ucs_topo_get_device_bus_id(sys_dev, &bus_id) != UCS_OK) {
ucs_fatal("failed to get device bus id for sys_dev %d", sys_dev);
}

return ucs_topo_get_bus_id_bit_repr(&bus_id);
}

static int ucp_proto_multi_sys_dev_cmp(const void *pa, const void *pb,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ucp_proto_multi_sys_dev_cmp here, ucs_topo_groups_sys_dev_cmp in topo_groups.c, and topo_test_sys_device_cmp in test_topo.cc are the same qsort_r trampoline. Can we export a qsort_r-compatible comparator from ucs/sys/topo/base/topo.h and drop this one and the gtest copy?

void *UCS_V_UNUSED arg)
{
const ucs_sys_device_t a = *(const ucs_sys_device_t*)pa;
const ucs_sys_device_t b = *(const ucs_sys_device_t*)pb;
ucs_bus_id_bit_rep_t key_a = ucp_proto_multi_sys_dev_bus_id_key(a);
ucs_bus_id_bit_rep_t key_b = ucp_proto_multi_sys_dev_bus_id_key(b);
uintptr_t user_value_a, user_value_b;

/* Sort by topology identity so every rank on the node observes the same
* ordering regardless of local device discovery order. */
if (key_a != key_b) {
return (key_a > key_b) - (key_a < key_b);
}

user_value_a = ucs_topo_sys_device_get_user_value(a);
user_value_b = ucs_topo_sys_device_get_user_value(b);
ucs_sys_device_t sys_dev1 = *(const ucs_sys_device_t*)pa;
ucs_sys_device_t sys_dev2 = *(const ucs_sys_device_t*)pb;

return (user_value_a > user_value_b) - (user_value_a < user_value_b);
return ucs_topo_sys_device_cmp(sys_dev1, sys_dev2);
}

static ucp_lane_index_t ucp_proto_multi_find_max_avail_bw_lane(
Comment thread
guy-ealey-morag marked this conversation as resolved.
Resolved
Expand Down
83 changes: 51 additions & 32 deletions src/ucs/sys/topo/base/topo.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,45 @@ ucs_topo_bus_value_key_make(const ucs_sys_bus_id_t *bus_id,
return key;
}

int ucs_topo_sys_device_cmp_nolock(ucs_sys_device_t sys_dev1,
ucs_sys_device_t sys_dev2)
{
const ucs_topo_sys_device_info_t *device1, *device2;
ucs_bus_id_bit_rep_t bus_id1, bus_id2;

ucs_assertv(sys_dev1 < ucs_topo_global_ctx.num_devices,
Comment thread
guy-ealey-morag marked this conversation as resolved.
Resolved
"invalid sys_dev1: %u", sys_dev1);
ucs_assertv(sys_dev2 < ucs_topo_global_ctx.num_devices,
"invalid sys_dev2: %u", sys_dev2);

device1 = &ucs_topo_global_ctx.devices[sys_dev1];
device2 = &ucs_topo_global_ctx.devices[sys_dev2];

/* Compare by bus id.*/
bus_id1 = ucs_topo_get_bus_id_bit_repr(&device1->bus_id);
bus_id2 = ucs_topo_get_bus_id_bit_repr(&device2->bus_id);

if (bus_id1 != bus_id2) {
return (bus_id1 > bus_id2) - (bus_id1 < bus_id2);
}

/* Compare by user value. */
return (device1->user_value > device2->user_value) -
(device1->user_value < device2->user_value);
}

int ucs_topo_sys_device_cmp(ucs_sys_device_t sys_dev1,
ucs_sys_device_t sys_dev2)
{
int result;

ucs_spin_lock(&ucs_topo_global_ctx.lock);
result = ucs_topo_sys_device_cmp_nolock(sys_dev1, sys_dev2);
ucs_spin_unlock(&ucs_topo_global_ctx.lock);

return result;
}

unsigned ucs_topo_num_devices()
{
unsigned num_devices;
Expand All @@ -283,17 +322,16 @@ static void ucs_topo_bus_id_str(const ucs_sys_bus_id_t *bus_id, int abbreviate,
char *str, size_t max)
{
if (abbreviate && (bus_id->domain == 0)) {
Comment thread
guy-ealey-morag marked this conversation as resolved.
Resolved
ucs_snprintf_safe(str, max, "%02x:%02x.%d", bus_id->bus, bus_id->slot,
bus_id->function);
ucs_snprintf_safe(str, max, UCS_SYS_BUS_ID_ABBREVIATED_FMT,
UCS_SYS_BUS_ID_ABBREVIATED_ARG(bus_id));
} else {
ucs_snprintf_safe(str, max, "%04x:%02x:%02x.%d", bus_id->domain,
bus_id->bus, bus_id->slot, bus_id->function);
ucs_snprintf_safe(str, max, UCS_SYS_BUS_ID_FMT,
UCS_SYS_BUS_ID_ARG(bus_id));
}
}

static ucs_status_t
ucs_topo_bus_id_to_sysfs_path(const ucs_sys_bus_id_t *bus_id, char *path,
size_t max)
ucs_status_t ucs_topo_bus_id_to_sysfs_path(const ucs_sys_bus_id_t *bus_id,
char *path, size_t max)
{
const size_t prefix_length = strlen(UCS_TOPO_SYSFS_PCI_PREFIX);
ucs_status_t status;
Expand Down Expand Up @@ -1366,44 +1404,25 @@ static void ucs_topo_release_devices()
}
}

static ucs_topo_groups_type_t ucs_topo_groups_type_detect()
{
return (ucs_arch_get_cpu_model() == UCS_CPU_MODEL_NVIDIA_VERA) ?
UCS_TOPO_GROUPS_TYPE_VERA_RUBIN :
UCS_TOPO_GROUPS_TYPE_UNKNOWN;
}

ucs_status_t ucs_topo_build_groups(ucs_topo_groups_t *groups_p)

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.

Residual coverage: ucs_topo_build_groups() still has no production caller and no gtest, so the collect/sort/alias-filter/CX9-fw_ver/element-grouping code added here is not exercised by CI, and ucs_topo_groups_build_groups() is still a stub that discards the inventory.

bot commented like above, could we add test to this pr addressing it and/or remove untested code? if it is from another pr could we maybe add some of them here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

{
ucs_status_t status;

if (ucs_arch_get_cpu_model() != UCS_CPU_MODEL_NVIDIA_VERA) {
Comment thread
guy-ealey-morag marked this conversation as resolved.
Resolved
/* Currently only Vera Rubin architecture supports topology groups. */
ucs_debug("topology groups are not supported on this architecture");
return UCS_ERR_UNSUPPORTED;
}

ucs_spin_lock(&ucs_topo_global_ctx.lock);
status = ucs_topo_build_groups_inner(ucs_topo_global_ctx.devices,
ucs_topo_global_ctx.num_devices,
ucs_topo_groups_type_detect(),
groups_p);
ucs_spin_unlock(&ucs_topo_global_ctx.lock);

return status;
}

static void ucs_topo_release_group(ucs_topo_group_t *group)
{
ucs_array_cleanup_dynamic(&group->nics);
ucs_array_cleanup_dynamic(&group->gpus);
}

void ucs_topo_release_groups(ucs_topo_groups_t *groups)
{
size_t i;

for (i = 0; i < ucs_array_length(&groups->groups); ++i) {
ucs_topo_release_group(&ucs_array_elem(&groups->groups, i));
}

ucs_array_cleanup_dynamic(&groups->groups);
}

ucs_global_state_t *ucs_topo_extract_state(void)
{
ucs_global_state_t *state;
Expand Down
29 changes: 29 additions & 0 deletions src/ucs/sys/topo/base/topo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ BEGIN_C_DECLS
/* Maximal size of BDF string */
#define UCS_SYS_BDF_NAME_MAX 16

/* Bus ID string formatting */
#define UCS_SYS_BUS_ID_FMT "%04x:%02x:%02x.%u"
#define UCS_SYS_BUS_ID_ARG(_bus_id) \
(unsigned)(_bus_id)->domain, (unsigned)(_bus_id)->bus, \
(unsigned)(_bus_id)->slot, (unsigned)(_bus_id)->function

/* Bus ID string formatting without the domain */
#define UCS_SYS_BUS_ID_ABBREVIATED_FMT "%02x:%02x.%u"
#define UCS_SYS_BUS_ID_ABBREVIATED_ARG(_bus_id) \
(unsigned)(_bus_id)->bus, (unsigned)(_bus_id)->slot, \
(unsigned)(_bus_id)->function

/* Special values for undefined PCI identifiers */
#define UCS_SYS_PCI_ID_VALUE_UNDEFINED 0x0000
#define UCS_SYS_PCI_ID_UNDEFINED \
Expand All @@ -48,6 +60,7 @@ BEGIN_C_DECLS
#define UCS_SYS_PCI_ID_FMT "[%04x:%04x]"
#define UCS_SYS_PCI_ID_ARG(_pci_id) ((_pci_id)->vendor), ((_pci_id)->device)


Comment thread
guy-ealey-morag marked this conversation as resolved.
Resolved
Comment thread
guy-ealey-morag marked this conversation as resolved.
Resolved
Comment thread
guy-ealey-morag marked this conversation as resolved.
Resolved
typedef struct ucs_sys_bus_id {
uint16_t domain; /* range: 0 to ffff */
uint8_t bus; /* range: 0 to ff */
Expand Down Expand Up @@ -262,6 +275,22 @@ ucs_bus_id_bit_rep_t
ucs_topo_get_bus_id_bit_repr(const ucs_sys_bus_id_t *bus_id);


/**
* Compare two system devices by their topology identity.
*
* Registered devices are ordered by PCI bus id, then by user-defined value.
* Device identifiers must be valid and registered (not UNKNOWN).
*
* @param [in] sys_dev1 First system device.
* @param [in] sys_dev2 Second system device.
*
* @return A negative value if @a sys_dev1 precedes @a sys_dev2, a positive
* value if @a sys_dev2 precedes @a sys_dev1, or zero if equal.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor: with this PR there are three identical ucs_qsort_r adapters around the comparator (ucp_proto_multi_sys_dev_cmp, topo_test_sys_device_cmp, and ucs_topo_groups_sys_dev_cmp). Can we also export a ucs_qsort_r-shaped ucs_topo_sys_device_qsort_cmp(const void*, const void*, void*) here, so the ucp and gtest wrappers can be removed?

*/
int ucs_topo_sys_device_cmp(ucs_sys_device_t sys_dev1,
ucs_sys_device_t sys_dev2);


/**
* Find the distance between two system devices (in terms of latency,
* bandwidth, hops, etc).
Expand Down
Loading
Loading