def __call__(self, partitioned_graph, machine): # check that the algorithm can handle the constraints utility_calls.check_algorithm_can_support_constraints( constrained_vertices=partitioned_graph.subvertices, supported_constraints=[ PlacerRadialPlacementFromChipConstraint, TagAllocatorRequireIptagConstraint, TagAllocatorRequireReverseIptagConstraint, PlacerChipAndCoreConstraint], abstract_constraint_type=AbstractPlacerConstraint) placements = Placements() ordered_subverts = utility_calls.sort_objects_by_constraint_authority( partitioned_graph.subvertices) # Iterate over subvertices and generate placements progress_bar = ProgressBar(len(ordered_subverts), "Placing graph vertices") resource_tracker = ResourceTracker( machine, self._generate_radial_chips(machine)) for vertex in ordered_subverts: self._place_vertex(vertex, resource_tracker, machine, placements) progress_bar.update() progress_bar.end() return {'placements': placements}
def convert_from_rig_placements(rig_placements, rig_allocations, partitioned_graph): placements = Placements() for vertex_id in rig_placements: vertex = partitioned_graph.get_subvertex_by_id(vertex_id) if vertex is not None: if isinstance(vertex, VirtualPartitionedVertex): placements.add_placement( Placement(vertex, vertex.virtual_chip_x, vertex.virtual_chip_y, None)) else: x, y = rig_placements[vertex_id] p = rig_allocations[vertex_id]["cores"].start placements.add_placement(Placement(vertex, x, y, p)) return placements
def __call__(self, partitioned_graph, machine): sorted_vertices = self._sort_vertices_for_one_to_one_connection( partitioned_graph) # check that the algorithm can handle the constraints utility_calls.check_algorithm_can_support_constraints( constrained_vertices=partitioned_graph.subvertices, supported_constraints=[ PlacerRadialPlacementFromChipConstraint, TagAllocatorRequireIptagConstraint, TagAllocatorRequireReverseIptagConstraint, PlacerChipAndCoreConstraint ], abstract_constraint_type=AbstractPlacerConstraint) placements = Placements() self._do_allocation(sorted_vertices, placements, machine) return {'placements': placements}
def __call__(self, partitioned_graph, machine): """ Place a partitioned_graph so that each subvertex is placed on a\ core :param partitioned_graph: The partitioned_graph to place :type partitioned_graph:\ :py:class:`pacman.model.partitioned_graph.partitioned_graph.PartitionedGraph` :return: A set of placements :rtype: :py:class:`pacman.model.placements.placements.Placements` :raise pacman.exceptions.PacmanPlaceException: If something\ goes wrong with the placement """ # check that the algorithm can handle the constraints utility_calls.check_algorithm_can_support_constraints( constrained_vertices=partitioned_graph.subvertices, supported_constraints=[PlacerChipAndCoreConstraint], abstract_constraint_type=AbstractPlacerConstraint) placements = Placements() ordered_subverts = utility_calls.sort_objects_by_constraint_authority( partitioned_graph.subvertices) # Iterate over subvertices and generate placements progress_bar = ProgressBar(len(ordered_subverts), "Placing graph vertices") resource_tracker = ResourceTracker(machine) for subvertex in ordered_subverts: # Create and store a new placement anywhere on the board (x, y, p, _, _) = resource_tracker.allocate_constrained_resources( subvertex.resources_required, subvertex.constraints) placement = Placement(subvertex, x, y, p) placements.add_placement(placement) progress_bar.update() progress_bar.end() return {'placements': placements}
def test_memory_io(): vertex = MyVertex() graph = MachineGraph("Test") graph.add_vertex(vertex) placements = Placements() placements.add_placement(Placement(vertex, 0, 0, 1)) transceiver = _MockTransceiver() temp = tempfile.mkdtemp() print("ApplicationDataFolder = {}".format(temp)) inputs = { "MemoryTransceiver": transceiver, "MemoryMachineGraph": graph, "MemoryPlacements": placements, "IPAddress": "testing", "ApplicationDataFolder": temp, "APPID": 30 } algorithms = ["WriteMemoryIOData"] executor = PACMANAlgorithmExecutor( algorithms, [], inputs, [], [], [], xml_paths=get_front_end_common_pacman_xml_paths()) executor.execute_mapping() assert (vertex._test_tag == vertex._tag)
import logging import os logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) for handler in logging.root.handlers: handler.setFormatter( logging.Formatter(fmt="%(asctime)-15s %(levelname)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S")) application_data = list() binaries = ExecutableTargets() iptags = list() reverse_iptags = list() buffered_tags = Tags() buffered_placements = Placements() routing_tables = MulticastRoutingTables() # database params socket_addresses = list() reports_states = ReportState(False, False, False, False, False, False, False, False, False, False) machine_name = "192.168.240.253" machine_version = 3 bmp_details = "None" down_chips = "None" down_cores = "None" number_of_boards = 1 height = None width = None
def __call__(self, placements, allocations, partitioned_graph, extended_machine, constraints): """ :param placements: :param allocations: :param partitioned_graph: :param extended_machine: :param constraints: :return: """ # load the json files file_placements, core_allocations, constraints = \ self._load_json_files(placements, allocations, constraints) # validate the json files against the schemas self._validate_file_read_data(file_placements, core_allocations, constraints) # drop the type and allocations bit of core allocations # (makes lower code simpler) core_allocations = core_allocations['allocations'] memory_placements = Placements() # process placements for vertex_id in file_placements: subvertex = partitioned_graph.get_subvertex_by_id(vertex_id) if vertex_id not in core_allocations: if subvertex is not None: # virtual chip or tag chip constraints_for_vertex = self._locate_constraints( vertex_id, constraints) external_device_constraints = \ self._valid_constraints_for_external_device( constraints_for_vertex) if len(external_device_constraints) != 0: # get data for virtual chip route_constraint = \ external_device_constraints['end_point'] route_direction = constants.EDGES( route_constraint['direction'].upper()) placement_constraint = \ external_device_constraints['placement'] coords = placement_constraint['location'] # locate virtual chip link = extended_machine.get_chip_at( coords[0], coords[1]).router.get_link(route_direction.value) destination_chip = extended_machine.get_chip_at( link.destination_x, link.destination_y) # create placement placements.add_placement( Placement(subvertex, destination_chip.x, destination_chip.y, None)) else: raise exceptions.PacmanConfigurationException( "I don't recognise this pattern of constraints for" " a vertex which does not have a placement") else: if subvertex is None: raise exceptions.PacmanConfigurationException( "Failed to locate the partitioned vertex in the " "partitioned graph with label {}".format(vertex_id)) else: memory_placements.add_placement( Placement(x=file_placements[vertex_id][0], y=file_placements[vertex_id][1], p=core_allocations[vertex_id][0], subvertex=subvertex)) # return the file format return {"placements": memory_placements}