I cam up with this snippet of code so I could find the PCI devices closest to 
where a process was running.  This works fine on a NUMA node.  However, on a 
non-NUMA node, it appears that the HWLOC bridge is not connected to anything.  
Therefore, I believe I just need to do something like 
hwloc_get_obj_by_type(topology, HWLOC_OBJ_BRIDGE, 0) when running on a non-NUMA 
node.  Does that seem correct?  Should I special case where I do not find a 
HWLOC_OBJ_NODE object?

    retval = hwloc_topology_init(&topology);
    retval = hwloc_topology_set_flags(topology, flags);
    retval = hwloc_topology_load(topology);
    newset = hwloc_bitmap_alloc();
    retval = hwloc_get_last_cpu_location(topology, newset, 0);

    /* Get the object that contains the cpuset */
    node = hwloc_get_first_largest_obj_inside_cpuset(topology, newset);

    /* Climb up from that object until we find HWLOC_OBJ_NODE */
    while (node->type != HWLOC_OBJ_NODE) {
        node = node->parent;
    }

    /* Now look for the HWLOC_OBJ_BRIDGE.  All PCI busses hanging off the
     * node will have one of these */
    bridge = hwloc_get_next_child(topology, node, NULL);
    while (bridge != NULL && bridge->type != HWLOC_OBJ_BRIDGE) {
        bridge = hwloc_get_next_child(topology, node, bridge);
    }
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

Reply via email to