Le 21/06/2013 17:50, Jiri Hladky a écrit :
> I have now changed it to
> hwloc_obj[0] = hwloc_get_first_largest_obj_inside_cpuset(topology,
> cpuset);
> hwloc_obj[1] = hwloc_obj[0]->parent;
> and tried both
> hwloc_topology_insert_misc_object_by_parent (topology,  hwloc_obj[0],
> data);
> hwloc_topology_insert_misc_object_by_parent (topology,  hwloc_obj[1],
> data);
>
> but lstopo will core dump with the XML file
> $lstopo --input /tmp/a.xml 
> lstopo: topology.c:1128: add_default_object_sets: Assertion
> `obj->cpuset' failed.
> Aborted (core dumped)
>

Should be fixed with the attached patch (already applied to trunk and
stable branches).
Things were totally buggy, looks like you were the very first one to
play with this and XML :)
thanks
Brice

commit c2d0c5c455c147276f364acf7e92a40d53f66f55
Author: bgoglin <bgoglin@4b44e086-7f34-40ce-a3bd-00e031736276>
List-Post: hwloc-devel@lists.open-mpi.org
Date:   Mon Jun 24 09:59:38 2013 +0000

    core: fix support for Misc objects added by parent

    Looks like nobody ever tried to load a XML that contains a Misc
    added by parent, it has been broken for ever.

    When added by cpuset, Misc get a cpuset as any object. Nothing to do.
    When added by parent, they become a new leaf, so they need either empty
    or NULL sets. Empty sets require lots of hacks to be properly handled by
    the core (so that they don't get ignored). So we keep using NULL sets
    instead and just fix a couple places to properly handle them (like I/O).

    By the way, cleanup the addition of default object sets.

    Thanks to Jirka Hladky for the report.



    git-svn-id: https://svn.open-mpi.org/svn/hwloc/trunk@5710 4b44e086-7f34-40ce-a3bd-00e031736276

diff --git a/src/topology.c b/src/topology.c
index e48bb81..8fad8dc 100644
--- a/src/topology.c
+++ b/src/topology.c
@@ -1205,11 +1205,18 @@ add_default_object_sets(hwloc_obj_t obj, int parent_has_sets)
   if (hwloc_obj_type_is_io(obj->type))
     return;

-  if (parent_has_sets || obj->cpuset) {
-    /* if the parent has non-NULL sets, or if the object has non-NULL cpusets,
-     * it must have non-NULL nodesets
-     */
+  if (parent_has_sets && obj->type != HWLOC_OBJ_MISC) {
+    /* non-MISC object must have cpuset if parent has one. */
     assert(obj->cpuset);
+  }
+
+  /* other sets must be consistent with main cpuset:
+   * check cpusets and add nodesets if needed.
+   *
+   * MISC may have no sets at all (if added by parent), or usual ones (if added by cpuset),
+   * but that's not easy to detect, so just make sure sets are consistent as usual.
+   */
+  if (obj->cpuset) {
     assert(obj->online_cpuset);
     assert(obj->complete_cpuset);
     assert(obj->allowed_cpuset);
@@ -1220,9 +1227,9 @@ add_default_object_sets(hwloc_obj_t obj, int parent_has_sets)
     if (!obj->allowed_nodeset)
       obj->allowed_nodeset = hwloc_bitmap_alloc_full();
   } else {
-    /* parent has no sets and object has NULL cpusets,
-     * it must have NULL nodesets
-     */
+    assert(!obj->online_cpuset);
+    assert(!obj->complete_cpuset);
+    assert(!obj->allowed_cpuset);
     assert(!obj->nodeset);
     assert(!obj->complete_nodeset);
     assert(!obj->allowed_nodeset);
@@ -1516,7 +1523,7 @@ remove_empty(hwloc_topology_t topology, hwloc_obj_t *pobj)

   if (obj->type != HWLOC_OBJ_NODE
       && !obj->first_child /* only remove if all children were removed above, so that we don't remove parents of NUMAnode */
-      && !hwloc_obj_type_is_io(obj->type)
+      && !hwloc_obj_type_is_io(obj->type) && obj->type != HWLOC_OBJ_MISC
       && obj->cpuset /* don't remove if no cpuset at all, there's likely a good reason why it's different from having an empty cpuset */
       && hwloc_bitmap_iszero(obj->cpuset)) {
     /* Remove empty children */

Reply via email to