If the user inserts one, don't remove it.
This relies on string info attributes (added in previous commits),
and we try to not look at these and strcmp() their value unless
all lights are green.
This commit fixes #103
This commit was SVN r5652.
Linux when full discovery with libpciaccess or libpci isn't available.
It misses bridges and device names.
* Misc
+ + Never merge Group objects that were added explicitly by the user with
+ hwloc_custom_insert_group_object_by_parent().
+ Add --with-hwloc-plugins-path to specify the install/load directories
of plugins.
+ Calling hwloc_topology_load() or hwloc_topology_set_*() on an already
for_each_child_safe(child, obj, pchild)
restrict_object_nodeset(topology, pchild, droppednodeset);
}
+
+/* we don't want to merge groups that were inserted explicitly with the custom interface */
+static int
+can_merge_group(hwloc_topology_t topology, hwloc_obj_t obj)
+{
+ const char *value;
+ /* custom-inserted groups are in custom topologies and have no cpusets,
+ * don't bother calling hwloc_obj_get_info_by_name() and strcmp() uselessly.
+ */
+ if (!topology->backends->is_custom || obj->cpuset)
+ return 1;
+ value = hwloc_obj_get_info_by_name(obj, "Backend");
+ return (!value) || strcmp(value, "Custom");
+}
+
/*
* Merge with the only child if either the parent or the child has a type to be
* ignored while keeping structure
child->next_sibling = NULL;
/* Check whether parent and/or child can be replaced */
- if (topology->ignored_types[parent->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE)
- /* Parent can be ignored in favor of the child. */
- replaceparent = 1;
- if (topology->ignored_types[child->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE)
- /* Child can be ignored in favor of the parent. */
- replacechild = 1;
+ if (topology->ignored_types[parent->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE) {
+ if (parent->type != HWLOC_OBJ_GROUP || can_merge_group(topology, parent))
+ /* Parent can be ignored in favor of the child. */
+ replaceparent = 1;
+ }
+ if (topology->ignored_types[child->type] == HWLOC_IGNORE_TYPE_KEEP_STRUCTURE) {
+ if (child->type != HWLOC_OBJ_GROUP || can_merge_group(topology, child))
+ /* Child can be ignored in favor of the parent. */
+ replacechild = 1;
+ }
/* Decide which one to actually replace */
if (replaceparent && replacechild) {
sw21 = hwloc_custom_insert_group_object_by_parent(global, sw2, 1);
hwloc_custom_insert_topology(global, sw21, local, NULL);
hwloc_custom_insert_topology(global, sw21, local, NULL);
+ hwloc_custom_insert_topology(global, sw21, local, NULL);
sw22 = hwloc_custom_insert_group_object_by_parent(global, sw2, 1);
- hwloc_custom_insert_topology(global, sw22, local, NULL);
- hwloc_custom_insert_topology(global, sw22, local, NULL);
+ hwloc_custom_insert_topology(global, sw22, local, NULL); /* only one to check that it won't get merged */
hwloc_topology_destroy(local);
assert(hwloc_get_depth_type(global, 1) == HWLOC_OBJ_GROUP);
assert(hwloc_get_nbobjs_by_depth(global, 1) == 2);
assert(hwloc_get_depth_type(global, 2) == HWLOC_OBJ_GROUP);
- assert(hwloc_get_nbobjs_by_depth(global, 2) == 4);
+ assert(hwloc_get_nbobjs_by_depth(global, 2) == 4); /* the last group of this level shouldn't be merged */
assert(hwloc_get_depth_type(global, 3) == HWLOC_OBJ_MACHINE);
assert(hwloc_get_nbobjs_by_type(global, HWLOC_OBJ_MACHINE) == 8);
assert(hwloc_get_depth_type(global, 4) == HWLOC_OBJ_NODE);