static void topology_init() { topo_topology_init(&topology); topo_topology_load(topology); topo_topology_get_info(topology, &topoinfo); depth = topo_get_type_or_below_depth(topology, TOPO_OBJ_CORE); cores = topo_get_depth_nbobjs(topology, depth); fprintf(stderr, "----------------- Dump toplogy[%ud] info -----------------\n", cores); /* Dump the toplogy info */ print_children(topology, topo_get_system_obj(topology), 0); fprintf(stderr, "----------------------------------------------------------\n"); }
/* check a whole topology structure */ void topo_topology_check(struct topo_topology *topology) { struct topo_topology_info info; struct topo_obj *obj; int i,j; topo_obj_type_t type; for (type = TOPO_OBJ_SYSTEM; type < TOPO_OBJ_TYPE_MAX; type++) assert(topo_get_order_type(topo_get_type_order(type)) == type); for (i = topo_get_order_type(TOPO_OBJ_SYSTEM); i <= topo_get_order_type(TOPO_OBJ_CORE); i++) assert(topo_get_type_order(topo_get_order_type(i)) == i); assert(topo_topology_get_info(topology, &info) >= 0); /* top-level specific checks */ assert(topo_get_depth_nbobjs(topology, 0) == 1); obj = topo_get_system_obj(topology); assert(obj); assert(obj->type == TOPO_OBJ_SYSTEM); /* check each level */ for(i=0; i<info.depth; i++) { unsigned width = topo_get_depth_nbobjs(topology, i); struct topo_obj *prev = NULL; /* check that each object is equal to the previous one */ for(j=0; j<width; j++) { obj = topo_get_obj_by_depth(topology, i, j); assert(obj); assert(obj->depth == i); assert(obj->logical_index == j); if (prev) { assert(topo_type_cmp(obj, prev) == TOPO_TYPE_EQUAL); assert(prev->next_cousin == obj); assert(obj->prev_cousin == prev); } topo__check_children(topology, obj); prev = obj; } /* check first object of the level */ obj = topo_get_obj_by_depth(topology, i, 0); assert(obj); assert(!obj->prev_cousin); /* check type */ assert(topo_get_depth_type(topology, i) == obj->type); assert(topo_get_type_depth(topology, obj->type) == i || topo_get_type_depth(topology, obj->type) == TOPO_TYPE_DEPTH_MULTIPLE); /* check last object */ obj = topo_get_obj_by_depth(topology, i, width-1); assert(obj); assert(!obj->next_cousin); /* check last+1 object */ obj = topo_get_obj_by_depth(topology, i, width); assert(!obj); } /* check bottom objects */ assert(topo_get_depth_nbobjs(topology, info.depth-1) > 0); for(j=0; j<topo_get_depth_nbobjs(topology, info.depth-1); j++) { obj = topo_get_obj_by_depth(topology, info.depth-1, j); assert(obj); assert(obj->type == TOPO_OBJ_PROC); assert(obj->arity == 0); assert(obj->children == NULL); } }