예제 #1
0
    void hwloc_topology::extract_node_mask(
        hwloc_obj_t parent
      , mask_type& mask
        ) const
    { // {{{
        hwloc_obj_t obj;

        {
            scoped_lock lk(topo_mtx);
            obj = hwloc_get_next_child(topo, parent, NULL);
        }

        while (obj)
        {
            if (hwloc_compare_types(HWLOC_OBJ_PU, obj->type) == 0)
            {
                do {
                    mask |= (static_cast<mask_type>(1) << obj->os_index);
                    {
                        scoped_lock lk(topo_mtx);
                        obj = hwloc_get_next_child(topo, parent, obj);
                    }
                } while (obj != NULL &&
                         hwloc_compare_types(HWLOC_OBJ_PU, obj->type) == 0);
                return;
            }

            extract_node_mask(obj, mask);

            scoped_lock lk(topo_mtx);
            obj = hwloc_get_next_child(topo, parent, obj);
        }
    } // }}}
예제 #2
0
    std::size_t hwloc_topology::extract_node_count(
        hwloc_obj_t parent
      , hwloc_obj_type_t type
      , std::size_t count
        ) const
    { // {{{
        hwloc_obj_t obj;

        {
            scoped_lock lk(topo_mtx);
            obj = hwloc_get_next_child(topo, parent, NULL);
        }

        while (obj)
        {
            if (hwloc_compare_types(type, obj->type) == 0)
            {
                do {
                    ++count;
                    {
                        scoped_lock lk(topo_mtx);
                        obj = hwloc_get_next_child(topo, parent, obj);
                    }
                } while (obj != NULL && hwloc_compare_types(type, obj->type) == 0);
                return count;
            }

            count = extract_node_count(obj, type, count);

            scoped_lock lk(topo_mtx);
            obj = hwloc_get_next_child(topo, parent, obj);
        }

        return count;
    } // }}}
예제 #3
0
/* next child, in all children list, ignoring PU if needed */
static hwloc_obj_t next_child(hwloc_topology_t topology, hwloc_obj_t parent, hwloc_obj_t prev)
{
  hwloc_obj_t obj = prev;
again:
  obj = hwloc_get_next_child(topology, parent, obj);
  if (!obj)
    return NULL;
  if (obj->type == HWLOC_OBJ_PU && lstopo_ignore_pus)
    goto again;
  if (lstopo_collapse && obj->type == HWLOC_OBJ_PCI_DEVICE) {
    const char *collapsestr = hwloc_obj_get_info_by_name(obj, "lstopoCollapse");
    if (collapsestr && !strcmp(collapsestr, "0"))
      goto again;
  }
  return obj;
}