Пример #1
0
def _ner_route(machine_graph, machine, placements, vector_to_nodes):
    """ Performs routing using rig algorithm

    :param MachineGraph machine_graph:
    :param ~spinn_machine.Machine machine:
    :param Placements placements:
    :return:
    :rtype: MulticastRoutingTableByPartition
    """
    routing_tables = MulticastRoutingTableByPartition()

    progress_bar = ProgressBar(len(machine_graph.vertices), "Routing")

    for source_vertex in progress_bar.over(machine_graph.vertices):
        # handle the vertex edges
        for partition in machine_graph.\
                get_multicast_edge_partitions_starting_at_vertex(
                    source_vertex):
            post_vertexes = list(e.post_vertex for e in partition.edges)
            routing_tree = _do_route(source_vertex, post_vertexes, machine,
                                     placements, vector_to_nodes)
            incoming_processor = placements.get_placement_of_vertex(
                partition.pre_vertex).p
            _convert_a_route(routing_tables, partition, incoming_processor,
                             None, routing_tree)

    progress_bar.end()

    return routing_tables
Пример #2
0
def convert_from_rig_routes(rig_routes):
    routing_tables = MulticastRoutingTableByPartition()
    for partition in rig_routes:
        partition_route = rig_routes[partition]
        _convert_next_route(routing_tables, partition, 0, None,
                            partition_route)
    return routing_tables
Пример #3
0
    def __call__(self,
                 placements,
                 machine,
                 machine_graph,
                 bw_per_route_entry=BW_PER_ROUTE_ENTRY,
                 max_bw=MAX_BW,
                 use_progress_bar=True):
        """ Find routes between the edges with the allocated information,\
            placed in the given places

        :param placements: The placements of the edges
        :type placements:\
            :py:class:`pacman.model.placements.Placements`
        :param machine: The machine through which the routes are to be found
        :type machine: :py:class:`spinn_machine.Machine`
        :param machine_graph: the machine_graph object
        :type machine_graph:\
            :py:class:`pacman.model.graphs.machine.MachineGraph`
        :param use_progress_bar: whether to show a progress bar
        :type use_progress_bar: bool
        :return: The discovered routes
        :rtype:\
            :py:class:`pacman.model.routing_tables.MulticastRoutingTables`
        :raise pacman.exceptions.PacmanRoutingException: \
            If something goes wrong with the routing
        """

        # set up basic data structures
        self._routing_paths = MulticastRoutingTableByPartition()
        self._bw_per_route_entry = bw_per_route_entry
        self._max_bw = max_bw
        self._machine = machine

        nodes_info = self._initiate_node_info(machine)
        tables = self._initiate_dijkstra_tables(machine)
        self._update_all_weights(nodes_info)

        # each vertex represents a core in the board
        pb_factory = ProgressBar if use_progress_bar else DummyProgressBar
        progress = pb_factory(placements.n_placements,
                              "Creating routing entries")

        for placement in progress.over(placements.placements):
            self._route(placement, placements, machine, machine_graph,
                        nodes_info, tables)
        return self._routing_paths
Пример #4
0
 def test_multicast_routing_table_by_partition(self):
     mrt = MulticastRoutingTableByPartition()
     partition = MulticastEdgePartition(None, "foo")
     entry = MulticastRoutingTableByPartitionEntry(range(4), range(2))
     mrt.add_path_entry(entry, 0, 0, partition)
     entry = MulticastRoutingTableByPartitionEntry(range(4, 8), range(2, 4))
     mrt.add_path_entry(entry, 0, 0, partition)
     entry = MulticastRoutingTableByPartitionEntry(range(8, 12),
                                                   range(4, 6))
     mrt.add_path_entry(entry, 0, 0, partition)
     assert list(mrt.get_routers()) == [(0, 0)]
     assert len(mrt.get_entries_for_router(0, 0)) == 1
     assert next(iter(mrt.get_entries_for_router(0, 0))) == partition
     mre = mrt.get_entries_for_router(0, 0)[partition]
     assert str(mre) == (
         "None:None:False:{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}"
         ":{0, 1, 2, 3, 4, 5}")
     assert mre == mrt.get_entry_on_coords_for_edge(partition, 0, 0)
    def __call__(self, file_routing_paths, partition_by_id):
        # load the JSON files
        file_routing_paths = self._handle_json_files(file_routing_paths)
        progress = ProgressBar(file_routing_paths,
                               "Converting to PACMAN routes")

        # iterate though the path for each edge and create entries
        routing_tables = MulticastRoutingTableByPartition()
        for partition_id in progress.over(file_routing_paths):
            partition = partition_by_id[partition_id]

            # if the vertex is none, its a vertex with the special skills of
            # needing no cores. therefore ignore
            if partition is not None:
                partition_route = file_routing_paths[partition_id]
                self._convert_next_route(routing_tables, partition, 0, None,
                                         partition_route)

        return routing_tables
 def __init__(self, machine, bw_per_route_entry, max_bw):
     # set up basic data structures
     self._routing_paths = MulticastRoutingTableByPartition()
     self._bw_per_route_entry = bw_per_route_entry
     self._max_bw = max_bw
     self._machine = machine