def __call__(self, partitioned_graph, graph_mapper): """ :param partitioned_graph: :param graph_mapper: :return: """ n_keys_map = DictBasedPartitionedEdgeNKeysMap() for edge in partitioned_graph.subedges: vertex_slice = graph_mapper.get_subvertex_slice( edge.pre_subvertex) super_edge = (graph_mapper .get_partitionable_edge_from_partitioned_edge(edge)) if not isinstance(super_edge.pre_vertex, AbstractProvidesNKeysForEdge): n_keys_map.set_n_keys_for_patitioned_edge(edge, vertex_slice.n_atoms) else: n_keys_map.set_n_keys_for_patitioned_edge( edge, super_edge.pre_vertex.get_n_keys_for_partitioned_edge( edge, graph_mapper)) if isinstance(super_edge.pre_vertex, AbstractProvidesOutgoingEdgeConstraints): edge.add_constraints( super_edge.pre_vertex.get_outgoing_edge_constraints( edge, graph_mapper)) if isinstance(super_edge.post_vertex, AbstractProvidesIncomingEdgeConstraints): edge.add_constraints( super_edge.post_vertex.get_incoming_edge_constraints( edge, graph_mapper)) return {'n_keys_map': n_keys_map}
def _execute_key_allocator(self, pacman_report_state): """ executes the key allocator :param pacman_report_state: :return: """ if self._key_allocator_algorithm is None: self._key_allocator_algorithm = BasicRoutingInfoAllocator() else: self._key_allocator_algorithm = self._key_allocator_algorithm() # execute routing info generator # Generate an n_keys map for the graph and add constraints n_keys_map = DictBasedPartitionedEdgeNKeysMap() for edge in self._partitioned_graph.subedges: vertex_slice = self._graph_mapper.get_subvertex_slice( edge.pre_subvertex) super_edge = (self._graph_mapper .get_partitionable_edge_from_partitioned_edge(edge)) if not isinstance(super_edge.pre_vertex, AbstractProvidesNKeysForEdge): n_keys_map.set_n_keys_for_patitioned_edge(edge, vertex_slice.n_atoms) else: n_keys_map.set_n_keys_for_patitioned_edge( edge, super_edge.pre_vertex.get_n_keys_for_partitioned_edge( edge, self._graph_mapper)) if isinstance(super_edge.pre_vertex, AbstractProvidesOutgoingEdgeConstraints): edge.add_constraints( super_edge.pre_vertex.get_outgoing_edge_constraints( edge, self._graph_mapper)) if isinstance(super_edge.post_vertex, AbstractProvidesIncomingEdgeConstraints): edge.add_constraints( super_edge.post_vertex.get_incoming_edge_constraints( edge, self._graph_mapper)) # execute routing info generator self._routing_infos = \ self._key_allocator_algorithm.allocate_routing_info( self._partitioned_graph, self._placements, n_keys_map) # generate reports if (pacman_report_state is not None and pacman_report_state.routing_info_report): pacman_reports.routing_info_reports( self._report_default_directory, self._partitioned_graph, self._routing_infos)
def __call__(self, partitioned_graph, graph_mapper): """ Generate an n_keys map for the graph and add constraints :param partitioned_graph: :param graph_mapper: :return: """ progress_bar = ProgressBar( len(partitioned_graph.subedges), "Deducing edge to number of keys map") n_keys_map = DictBasedPartitionedEdgeNKeysMap() for edge in partitioned_graph.subedges: vertex_slice = graph_mapper.get_subvertex_slice( edge.pre_subvertex) super_edge = (graph_mapper .get_partitionable_edge_from_partitioned_edge(edge)) if not isinstance(super_edge.pre_vertex, AbstractProvidesNKeysForEdge): n_keys_map.set_n_keys_for_patitioned_edge(edge, vertex_slice.n_atoms) else: n_keys_map.set_n_keys_for_patitioned_edge( edge, super_edge.pre_vertex.get_n_keys_for_partitioned_edge( edge, graph_mapper)) if isinstance(super_edge.pre_vertex, AbstractProvidesOutgoingEdgeConstraints): edge.add_constraints( super_edge.pre_vertex.get_outgoing_edge_constraints( edge, graph_mapper)) if isinstance(super_edge.post_vertex, AbstractProvidesIncomingEdgeConstraints): edge.add_constraints( super_edge.post_vertex.get_incoming_edge_constraints( edge, graph_mapper)) progress_bar.update() progress_bar.end() return {'n_keys_map': n_keys_map}
def _execute_key_allocator(self, pacman_report_state): """ executes the key allocator :param pacman_report_state: :return: """ if self._key_allocator_algorithm is None: self._key_allocator_algorithm = BasicRoutingInfoAllocator() else: self._key_allocator_algorithm = self._key_allocator_algorithm() # execute routing info generator # Generate an n_keys map for the graph and add constraints n_keys_map = DictBasedPartitionedEdgeNKeysMap() for edge in self._partitioned_graph.subedges: vertex_slice = self._graph_mapper.get_subvertex_slice( edge.pre_subvertex) super_edge = (self._graph_mapper. get_partitionable_edge_from_partitioned_edge(edge)) if not isinstance(super_edge.pre_vertex, AbstractProvidesNKeysForEdge): n_keys_map.set_n_keys_for_patitioned_edge( edge, vertex_slice.n_atoms) else: n_keys_map.set_n_keys_for_patitioned_edge( edge, super_edge.pre_vertex.get_n_keys_for_partitioned_edge( edge, self._graph_mapper)) if isinstance(super_edge.pre_vertex, AbstractProvidesOutgoingEdgeConstraints): edge.add_constraints( super_edge.pre_vertex.get_outgoing_edge_constraints( edge, self._graph_mapper)) if isinstance(super_edge.post_vertex, AbstractProvidesIncomingEdgeConstraints): edge.add_constraints( super_edge.post_vertex.get_incoming_edge_constraints( edge, self._graph_mapper)) # execute routing info generator self._routing_infos = \ self._key_allocator_algorithm.allocate_routing_info( self._partitioned_graph, self._placements, n_keys_map) # generate reports if (pacman_report_state is not None and pacman_report_state.routing_info_report): pacman_reports.routing_info_reports(self._report_default_directory, self._partitioned_graph, self._routing_infos)