Esempio n. 1
0
    def _add_mach_lpg_vertex(self, chip, params):
        """ Adds a LPG vertex to a machine graph without an associated\
            application graph.

        :param ~.Chip chip:
        :param LivePacketGatherParameters params:
        :rtype: LivePacketGatherMachineVertex
        """
        vtx = LivePacketGatherMachineVertex(
            params, constraints=[ChipAndCoreConstraint(x=chip.x, y=chip.y)])
        self._machine_graph.add_vertex(vtx)
        return vtx
Esempio n. 2
0
    def __init__(self, label):
        args = LivePacketGatherParameters(
            port=globals.ack_port,
            hostname=globals.host,
            strip_sdp=True,
            message_type=EIEIOType.KEY_PAYLOAD_32_BIT,
            use_payload_prefix=False,
            payload_as_time_stamps=False)

        machine_vertex = LivePacketGatherMachineVertex(
            args, label=label, constraints=[ChipAndCoreConstraint(x=0, y=0)])

        super(Extractor, self).__init__(label, 1, [machine_vertex])
Esempio n. 3
0
    def test_local_verts_go_to_local_lpgs(self):
        machine = VirtualMachine(width=12, height=12, with_wrap_arounds=True)
        graph = MachineGraph("Test")

        default_params = {
            'use_prefix': False,
            'key_prefix': None,
            'prefix_type': None,
            'message_type': EIEIOType.KEY_32_BIT,
            'right_shift': 0,
            'payload_as_time_stamps': True,
            'use_payload_prefix': True,
            'payload_prefix': None,
            'payload_right_shift': 0,
            'number_of_packets_sent_per_time_step': 0,
            'hostname': None,
            'port': None,
            'strip_sdp': None,
            'board_address': None,
            'tag': None,
            'label': "test"
        }

        # data stores needed by algorithm
        live_packet_gatherers = dict()
        extended = dict(default_params)
        extended.update({'partition_id': "EVENTS"})
        default_params_holder = LivePacketGatherParameters(**extended)
        live_packet_gatherers[default_params_holder] = list()

        live_packet_gatherers_to_vertex_mapping = dict()
        live_packet_gatherers_to_vertex_mapping[default_params_holder] = dict()

        placements = Placements()

        # add LPG's (1 for each Ethernet connected chip)
        for chip in machine.ethernet_connected_chips:
            vertex = LivePacketGatherMachineVertex(**default_params)
            graph.add_vertex(vertex)
            placements.add_placement(
                Placement(x=chip.x, y=chip.y, p=2, vertex=vertex))
            live_packet_gatherers_to_vertex_mapping[default_params_holder][
                chip.x, chip.y] = vertex

        # tracker of wirings
        verts_expected = defaultdict(list)
        positions = list()
        positions.append([0, 0, 0, 0])
        positions.append([4, 4, 0, 0])
        positions.append([1, 1, 0, 0])
        positions.append([2, 2, 0, 0])
        positions.append([8, 4, 8, 4])
        positions.append([11, 4, 8, 4])
        positions.append([4, 11, 4, 8])
        positions.append([4, 8, 4, 8])
        positions.append([0, 11, 8, 4])
        positions.append([11, 11, 4, 8])
        positions.append([8, 8, 4, 8])
        positions.append([4, 0, 0, 0])
        positions.append([7, 7, 0, 0])

        # add graph vertices which reside on areas of the machine to ensure
        #  spread over boards.
        for x, y, eth_x, eth_y in positions:
            vertex = SimpleMachineVertex(resources=ResourceContainer())
            graph.add_vertex(vertex)
            live_packet_gatherers[default_params_holder].append(vertex)
            verts_expected[eth_x, eth_y].append(vertex)
            placements.add_placement(Placement(x=x, y=y, p=5, vertex=vertex))

        # run edge inserter that should go boom
        edge_inserter = InsertEdgesToLivePacketGatherers()
        edge_inserter(live_packet_gatherer_parameters=live_packet_gatherers,
                      placements=placements,
                      live_packet_gatherers_to_vertex_mapping=(
                          live_packet_gatherers_to_vertex_mapping),
                      machine=machine,
                      machine_graph=graph,
                      application_graph=None,
                      graph_mapper=None)

        # verify edges are in the right place
        for chip in machine.ethernet_connected_chips:
            edges = graph.get_edges_ending_at_vertex(
                live_packet_gatherers_to_vertex_mapping[default_params_holder][
                    chip.x, chip.y])
            for edge in edges:
                self.assertIn(edge.pre_vertex, verts_expected[chip.x, chip.y])
Esempio n. 4
0
    def test_local_verts_when_multiple_lpgs_are_local(self):
        machine = virtual_machine(width=12, height=12)
        graph = MachineGraph("Test")

        default_params = {
            'use_prefix': False,
            'key_prefix': None,
            'prefix_type': None,
            'message_type': EIEIOType.KEY_32_BIT,
            'right_shift': 0,
            'payload_as_time_stamps': True,
            'use_payload_prefix': True,
            'payload_prefix': None,
            'payload_right_shift': 0,
            'number_of_packets_sent_per_time_step': 0,
            'hostname': None,
            'port': None,
            'strip_sdp': None,
            'tag': None,
            'label': "Test"}

        # data stores needed by algorithm
        live_packet_gatherers = dict()
        default_params_holder = LivePacketGatherParameters(**default_params)
        live_packet_gatherers[default_params_holder] = list()

        live_packet_gatherers_to_vertex_mapping = defaultdict(dict)

        placements = Placements()

        # add LPG's (1 for each Ethernet connected chip)

        specific_data_holders = dict()
        index = 1
        for chip in machine.ethernet_connected_chips:
            extended = dict(default_params)
            vertex = LivePacketGatherMachineVertex(
                LivePacketGatherParameters(**extended), label='test')
            graph.add_vertex(vertex)
            placements.add_placement(
                Placement(x=chip.x, y=chip.y, p=2, vertex=vertex))
            live_packet_gatherers_to_vertex_mapping[
                default_params_holder][chip.x, chip.y] = vertex

            # Add another on each chip separately
            index += 1
            extended = dict(default_params)
            extended['board_address'] = chip.ip_address
            default_params_holder2 = LivePacketGatherParameters(**extended)

            extended = dict(default_params)
            extended.update({'label': "test"})
            vertex = LivePacketGatherMachineVertex(
                LivePacketGatherParameters(**extended))
            specific_data_holders[(chip.x, chip.y)] = default_params_holder2
            placements.add_placement(Placement(
                x=chip.x, y=chip.y, p=3, vertex=vertex))
            graph.add_vertex(vertex)
            live_packet_gatherers_to_vertex_mapping[
                default_params_holder2][chip.x, chip.y] = vertex
            live_packet_gatherers[default_params_holder2] = list()

        # tracker of wirings
        verts_expected = defaultdict(list)

        positions = list()
        positions.append([0, 0, 0, 0, 2, default_params_holder])
        positions.append([4, 4, 0, 0, 2, default_params_holder])
        positions.append(
            [1, 1, 0, 0, 3, specific_data_holders[(0, 0)]])
        positions.append(
            [2, 2, 0, 0, 3, specific_data_holders[(0, 0)]])
        positions.append([8, 4, 8, 4, 2, default_params_holder])
        positions.append([11, 4, 8, 4, 2, default_params_holder])
        positions.append([4, 11, 4, 8, 2, default_params_holder])
        positions.append([4, 8, 4, 8, 2, default_params_holder])
        positions.append([0, 11, 8, 4, 3, specific_data_holders[(8, 4)]])
        positions.append([11, 11, 4, 8, 3, specific_data_holders[(4, 8)]])
        positions.append([8, 8, 4, 8, 3, specific_data_holders[(4, 8)]])
        positions.append([4, 0, 0, 0, 3, specific_data_holders[(0, 0)]])
        positions.append([7, 7, 0, 0, 2, default_params_holder])

        # add graph vertices which reside on areas of the machine to ensure
        #  spread over boards.
        for x, y, eth_x, eth_y, eth_p, params in positions:
            vertex = SimpleMachineVertex(resources=ResourceContainer())
            graph.add_vertex(vertex)
            live_packet_gatherers[params].append((vertex, ["EVENTS"]))
            verts_expected[eth_x, eth_y, eth_p].append(vertex)
            placements.add_placement(Placement(x=x, y=y, p=5, vertex=vertex))

        # run edge inserter that should go boom
        edge_inserter = InsertEdgesToLivePacketGatherers()
        edge_inserter(
            live_packet_gatherer_parameters=live_packet_gatherers,
            placements=placements,
            live_packet_gatherers_to_vertex_mapping=(
                live_packet_gatherers_to_vertex_mapping),
            machine=machine, machine_graph=graph, application_graph=None)

        # verify edges are in the right place
        for chip in machine.ethernet_connected_chips:
            for params, p in zip(
                    (default_params_holder,
                     specific_data_holders[chip.x, chip.y]),
                    (2, 3)):
                edges = graph.get_edges_ending_at_vertex(
                    live_packet_gatherers_to_vertex_mapping[
                        params][chip.x, chip.y])
                for edge in edges:
                    self.assertIn(
                        edge.pre_vertex, verts_expected[chip.x, chip.y, p])