static void topology_bind_core() { topo_obj_t obj; topo_cpuset_t cpuset; CMCore *self = coremu_get_core_self(); int index; index = (self->serial % cores); obj = topo_get_obj_by_depth(topology, depth, index); cpuset = obj->cpuset; topo_cpuset_singlify(&cpuset); if (topo_set_cpubind(topology, &cpuset, TOPO_CPUBIND_THREAD)) { char s[TOPO_CPUSET_STRING_LENGTH + 1]; topo_cpuset_snprintf(s, sizeof(s), &obj->cpuset); printf("Couldn't bind to cpuset %s\n", s); exit(-1); } //fprintf(stderr, "core [%u] binds to %d\n", self->serial, index); }
/* 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); } }