def test_redundant_paths_spinn7_via_router_require_turn(): the_machine = machine.Machine('spinn-7', type="spinn4") src_vertex_constraints = lib_map.VertexConstraints(x=0, y=0) src_vrt = graph.Vertex(1,models.IF_curr_exp, constraints=src_vertex_constraints) src_sub_vert = graph.Subvertex(src_vrt, 0,1) dest_vertex_constraints = lib_map.VertexConstraints(x=2, y=3) dest_vrt = graph.Vertex(1,models.IF_curr_exp, constraints=dest_vertex_constraints) dest_sub_vert = graph.Subvertex(dest_vrt, 0,1) dest_sub_vert2 = graph.Subvertex(dest_vrt, 0,1) edge = graph.Edge(None, src_vrt, dest_vrt) sbedge = graph.Subedge(edge, src_sub_vert, dest_sub_vert) sbedge2 = graph.Subedge(edge, src_sub_vert, dest_sub_vert2) dao_object = dao #place vertexes in correct cores placements = Placer.place_raw(the_machine, [src_sub_vert, dest_sub_vert, dest_sub_vert2]) dao.placements = placements routings = dijkstra_routing.DijkstraRouting.\ route_raw(the_machine, [src_sub_vert, dest_sub_vert, dest_sub_vert2]) inconsistant_routings, redundant_paths = \ Router.check_for_inconsistant_routings(the_machine) assert(len(redundant_paths) > 0) assert(len(inconsistant_routings) == 0) Router.redundant_path_removal(redundant_paths, the_machine) inconsistant_routings, redundant_paths = \ Router.check_for_inconsistant_routings(the_machine) assert(len(redundant_paths) == 0) assert(len(inconsistant_routings) == 0)
def partition_virtual_vertexes(self, vertex, placements, subvertices, placer): ''' handle the paritioning of virtual vertexes ''' #ask the vertex how many sub verts to split it into to. number_of_sub_verts = vertex.split_into_subvertex_count() number_per_subvert = vertex.atoms / number_of_sub_verts for subvert_count in range(number_of_sub_verts): #create a subvert start = (subvert_count * number_per_subvert) end = start + number_per_subvert - 1 subvertex = graph.Subvertex(vertex, start, end, 0) subvertices.append(subvertex) # Update the constraint to reflect changes if there are # more than 1 subvert if vertex.constraints.p is not None: start_constraint = \ lib_map.VertexConstraints(vertex.constraints.x, vertex.constraints.y, vertex.constraints.p + subvert_count) else: start_constraint = vertex.constraints # Place the subvertex chip = self.dao.machine.get_chip(vertex.constraints.x, vertex.constraints.y) x, y, p = placer.place_virtual_subvertex(start_constraint, chip.get_processors()) processor = self.dao.machine.get_processor(x, y, p) placement = lib_map.Placement(subvertex, processor) placements.append(placement) self.progress.update(vertex.atoms)
def test_redundant_paths_spinn7_via_router_same_chip(): the_machine = machine.Machine('spinn-7', type="spinn4") src_vertex_constraints = lib_map.VertexConstraints(x=0, y=0, p=2) src_vrt = graph.Vertex(1, models.IF_curr_exp, constraints=src_vertex_constraints) src_sub_vert = graph.Subvertex(src_vrt, 0,1) dest_vertex_constraints = lib_map.VertexConstraints(x=0, y=0, p=5) dest_vrt = graph.Vertex(1, models.IF_curr_exp, constraints=dest_vertex_constraints) dest_sub_vert = graph.Subvertex(dest_vrt, 0,1) dest_sub_vert2 = graph.Subvertex(dest_vrt, 0,1) dest_vertex_constraints2 = lib_map.VertexConstraints(x=0, y=0, p=6) dest_vrt2 = graph.Vertex(1, models.IF_curr_exp, constraints=dest_vertex_constraints2) dest_sub_vert2 = graph.Subvertex(dest_vrt2, 0, 1) edge = graph.Edge(None, src_vrt, dest_vrt) sbedge = graph.Subedge(edge, src_sub_vert, dest_sub_vert) sbedge2 = graph.Subedge(edge, src_sub_vert, dest_sub_vert2) dao_object = dao #place vertexes in correct cores placements = Placer.place_raw(the_machine, [src_sub_vert, dest_sub_vert, dest_sub_vert2]) dao.placements = placements routings = dijkstra_routing.\ DijkstraRouting.route_raw(the_machine, [src_sub_vert, dest_sub_vert, dest_sub_vert2]) inconsistant_routings, redundant_paths = \ Router.check_for_inconsistant_routings(the_machine) assert(len(redundant_paths) > 0) assert(len(inconsistant_routings) == 0) #print "entry {} and entry {}".format(redundant_paths[0][2].route, redundant_paths[0][3].route) Router.redundant_path_removal(redundant_paths, the_machine) inconsistant_routings, redundant_paths = \ Router.check_for_inconsistant_routings(the_machine) assert(len(redundant_paths) == 0) assert(len(inconsistant_routings) == 0) for key in the_machine.chips[0][0].router.cam.keys(): entry_list = the_machine.chips[0][0].router.cam.get(key) assert(len(entry_list) == 1) #print "entry is {}".format(entry_list[0].route) assert(entry_list[0].route == 6144)
def __init__(self, constraints=None, label="External Spike Source"): """ Creates a new AppMonitor Object. """ super(ExternalSpikeSource, self).__init__(n_neurons=1, constraints=lib_map.VertexConstraints(x=0, y=0), label=label)
def __init__(self): """ Creates a new AppMonitor Object. """ super( AppMonitor, self ).__init__( n_neurons = 1, constraints = lib_map.VertexConstraints(x = 0, y = 0), label = "Monitor" )
def set_mapping_constraint(self, constraint): """ Apply a constraint to a population that restricts the processor onto which its sub-populations will be placed. """ placementConstraint = lib_map.VertexConstraints() if 'x' in constraint: placementConstraint.x = constraint['x'] if 'y' in constraint: placementConstraint.y = constraint['y'] if 'p' in constraint: placementConstraint.p = constraint['p'] self.vertex.constraints = placementConstraint
def __init__( self, atoms, constraints=None, label=None, virtual=False): # Record passed parameters self.atoms = atoms if constraints is None: self.constraints = lib_map.VertexConstraints() else: self.constraints = constraints if label == None: label = "Vertex {}".format(Vertex.counter) Vertex.counter += 1 self.label = label self.virtual = virtual self.flags = 0 # Set up reference lists to subvertices and edges self.subvertices = list() self.in_edges = list() self.out_edges = list()
def try_creating_route(source, dests, machine_id): ''' create vertexes subverts and placements, run routing, and start backward chasing ''' the_machine = None #initilise machine description = machines.machines[machine_id] the_machine = machine.Machine(**description) subedges = dict() sub_verts = list() src_vertex_constraints = lib_map.VertexConstraints(x=source[0], y=source[1], p=source[2]) src_vrt = models.IF_curr_exp(1, constraints=src_vertex_constraints) src_sub_vert = graph.Subvertex(src_vrt, 0, 1, 0) sub_verts.append(src_sub_vert) #place vertexes in correct cores placement_chip = the_machine.get_chip( src_sub_vert.vertex.constraints.x, src_sub_vert.vertex.constraints.y) placement_processor = placement_chip.get_processor( src_sub_vert.vertex.constraints.p) placement = lib_map.Placement(src_sub_vert, placement_processor) src_sub_vert.placement = placement #add subvert and edge for each destination vertex dest_subverts = list() for dest in dests: dest_vertex_constraints = lib_map.VertexConstraints(x=dest[0], y=dest[1], p=dest[2]) dest_vrt = models.IF_curr_exp(1, constraints=dest_vertex_constraints) dest_sub_vert = graph.Subvertex(dest_vrt, 0, 1, 0) edge = graph.Edge(src_vrt, dest_vrt) sbedge = graph.Subedge(edge, src_sub_vert, dest_sub_vert) #give its routing key and mask key, mask = src_sub_vert.vertex.generate_routing_info(sbedge) sbedge.key = key sbedge.mask = mask sbedge.key_mask_combo = key & mask subedges[dest_sub_vert] = sbedge sub_verts.append(dest_sub_vert) dest_subverts.append(dest_sub_vert) #place vertexes in correct cores placement_chip = the_machine.get_chip( dest_sub_vert.vertex.constraints.x, dest_sub_vert.vertex.constraints.y) placement_processor = placement_chip.get_processor( dest_sub_vert.vertex.constraints.p) placement = lib_map.Placement(dest_sub_vert, placement_processor) dest_sub_vert.placement = placement fails = list() #try to route between the verts try: dijkstra_routing.DijkstraRouting.route_raw(the_machine, sub_verts) return src_sub_vert, dest_subverts, machine, subedges, None except Exception as e: print traceback.print_exc(e) return src_sub_vert, dest_subverts, machine, subedges, \ fails.append([src_sub_vert, dests, "failed to generate a route"])