Skip to content

Commit 577b327

Browse files
committed
core: fix group->total_memory after hwloc_topology_insert_group_object()
It was kept as 0. The issue was never detected because our tests use synthetic topologies with empty nodes (changed in next commit). Signed-off-by: Brice Goglin <[email protected]>
1 parent af43952 commit 577b327

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

hwloc/topology.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ hwloc_replace_linked_object(hwloc_obj_t old, hwloc_obj_t new)
646646
new->memory_first_child = old->memory_first_child;
647647
new->io_first_child = old->io_first_child;
648648
new->misc_first_child = old->misc_first_child;
649+
new->total_memory = old->total_memory;
649650
/* copy new contents to old now that tree pointers are OK */
650651
memcpy(old, new, sizeof(*old));
651652
/* clear new to that we may free it */
@@ -1934,7 +1935,7 @@ static int hwloc_connect_special_levels(hwloc_topology_t topology);
19341935
hwloc_obj_t
19351936
hwloc_topology_insert_group_object(struct hwloc_topology *topology, hwloc_obj_t obj)
19361937
{
1937-
hwloc_obj_t res, root;
1938+
hwloc_obj_t res, root, child;
19381939
int cmp;
19391940

19401941
if (!(topology->state & HWLOC_TOPOLOGY_STATE_IS_LOADED)) {
@@ -2023,6 +2024,13 @@ hwloc_topology_insert_group_object(struct hwloc_topology *topology, hwloc_obj_t
20232024
if (hwloc_topology_reconnect(topology, 0) < 0)
20242025
return NULL;
20252026

2027+
/* Compute group total_memory. */
2028+
obj->total_memory = 0;
2029+
for_each_child(child, obj)
2030+
obj->total_memory += child->total_memory;
2031+
for_each_memory_child(child, obj)
2032+
obj->total_memory += child->total_memory;
2033+
20262034
hwloc_propagate_symmetric_subtree(topology, topology->levels[0][0]);
20272035
hwloc_set_group_depth(topology);
20282036

0 commit comments

Comments
 (0)