Exemple #1
0
    def test_one_lpg_params_and_3_specific(self):
        machine = virtual_machine(width=12, height=12)

        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()

        # and special LPG on Ethernet connected chips
        for chip in machine.ethernet_connected_chips:
            extended = dict(default_params)
            extended['board_address'] = chip.ip_address
            default_params_holder2 = LivePacketGatherParameters(**extended)
            live_packet_gatherers[default_params_holder2] = list()

        pre_alloc = PreAllocateResourcesForLivePacketGatherers()
        pre_res = pre_alloc(
            live_packet_gatherer_parameters=live_packet_gatherers,
            machine=machine)

        # verify sdram
        locs = [(0, 0), (4, 8), (8, 4)]
        sdrams = pre_res.specific_sdram_usage
        for sdram in sdrams:
            locs.remove((sdram.chip.x, sdram.chip.y))
            self.assertEqual(
                sdram.sdram_usage.get_total_sdram(0),
                LivePacketGatherMachineVertex.get_sdram_usage() * 2)
        self.assertEqual(len(locs), 0)

        # verify cores
        locs = {(0, 0): 0, (4, 8): 0, (8, 4): 0}
        cores = pre_res.core_resources
        for core in cores:
            locs[core.chip.x, core.chip.y] += core.n_cores

        for (x, y) in [(0, 0), (4, 8), (8, 4)]:
            self.assertEqual(locs[x, y], 2)

        # verify specific cores
        self.assertEqual(len(pre_res.specific_core_resources), 0)
Exemple #2
0
    def test_that_6_lpgs_are_generated_2_on_each_eth_chip(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()

        # and special LPG on Ethernet connected chips
        index = 1
        chip_special = dict()
        for chip in machine.ethernet_connected_chips:
            extended['label'] = "test{}".format(index)
            extended['board_address'] = chip.ip_address
            default_params_holder2 = LivePacketGatherParameters(**extended)
            live_packet_gatherers[default_params_holder2] = list()
            chip_special[(chip.x, chip.y)] = default_params_holder2

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

        self.assertEqual(len(lpg_verts_mapping[default_params_holder]), 3)

        for eth_chip in chip_special:
            params = chip_special[eth_chip]
            self.assertEqual(len(lpg_verts_mapping[params]), 1)
            vertex = lpg_verts_mapping[params][eth_chip]
            self.assertEqual(eth_chip[0], list(vertex.constraints)[0].x)
            self.assertEqual(eth_chip[1], list(vertex.constraints)[0].y)
    def test_one_lpg_params(self):
        machine = virtual_machine(width=12, height=12, with_wrap_arounds=True)

        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}

        # 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()

        # run  pre allocator
        pre_alloc = PreAllocateResourcesForLivePacketGatherers()
        pre_res = pre_alloc(
            live_packet_gatherer_parameters=live_packet_gatherers,
            machine=machine)

        locs = list()
        locs.append((0, 0))
        locs.append((4, 8))
        locs.append((8, 4))

        # verify sdram
        sdrams = pre_res.specific_sdram_usage
        for sdram in sdrams:
            locs.remove((sdram.chip.x, sdram.chip.y))
            self.assertEqual(
                sdram.sdram_usage.get_total_sdram(0),
                LivePacketGatherMachineVertex.get_sdram_usage())
        self.assertEqual(len(locs), 0)

        locs = list()
        locs.append((0, 0))
        locs.append((4, 8))
        locs.append((8, 4))
        # verify cores
        cores = pre_res.core_resources
        for core in cores:
            locs.remove((core.chip.x, core.chip.y))
            self.assertEqual(core.n_cores, 1)
        self.assertEqual(len(locs), 0)

        # verify specific cores
        self.assertEqual(len(pre_res.specific_core_resources), 0)
Exemple #4
0
    def update_live_packet_gather_tracker(
            vertex_to_record_from, lpg_label, port=None, hostname=None,
            board_address=None, tag=None, strip_sdp=True, 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,
            partition_ids=None):
        """ Add an edge from a vertex to the live packet gatherer, builds as\
            needed and has all the parameters for the creation of the live\
            packet gatherer if needed.
        """
        # pylint: disable=too-many-arguments, too-many-locals
        params = LivePacketGatherParameters(
            port=port, hostname=hostname, tag=tag, board_address=board_address,
            strip_sdp=strip_sdp, use_prefix=use_prefix, key_prefix=key_prefix,
            prefix_type=prefix_type, message_type=message_type,
            right_shift=right_shift, payload_prefix=payload_prefix,
            payload_as_time_stamps=payload_as_time_stamps,
            use_payload_prefix=use_payload_prefix,
            payload_right_shift=payload_right_shift,
            number_of_packets_sent_per_time_step=(
                number_of_packets_sent_per_time_step),
            label=lpg_label)

        # add to the tracker
        get_simulator().add_live_packet_gatherer_parameters(
            params, vertex_to_record_from, partition_ids)
    def test_that_3_lpgs_are_generated_on_3_board_app_graph(self):
        machine = virtual_machine(width=12, height=12)
        app_graph = ApplicationGraph("Test")
        graph = MachineGraph("Test", app_graph)

        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()

        # run edge inserter that should go boom
        edge_inserter = InsertLivePacketGatherersToGraphs()
        lpg_verts_mapping = edge_inserter(
            live_packet_gatherer_parameters=live_packet_gatherers,
            machine=machine, machine_graph=graph, application_graph=app_graph)

        self.assertEqual(len(lpg_verts_mapping[default_params_holder]), 3)
        locs = list()
        locs.append((0, 0))
        locs.append((4, 8))
        locs.append((8, 4))
        for vertex in itervalues(lpg_verts_mapping[default_params_holder]):
            x = list(vertex.constraints)[0].x
            y = list(vertex.constraints)[0].y
            key = (x, y)
            locs.remove(key)

        self.assertEqual(len(locs), 0)

        verts = lpg_verts_mapping[default_params_holder].values()
        for vertex in graph.vertices:
            self.assertIn(vertex, verts)

        app_verts = set()
        for vertex in itervalues(lpg_verts_mapping[default_params_holder]):
            app_vertex = vertex.app_vertex
            self.assertNotEqual(app_vertex, None)
            self.assertIsInstance(app_vertex, ApplicationVertex)
            app_verts.add(app_vertex)
        self.assertEqual(len(app_verts), 3)
Exemple #6
0
    def test_that_3_lpgs_are_generated_on_3_board(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()

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

        self.assertEqual(len(lpg_verts_mapping[default_params_holder]), 3)
        locs = list()
        locs.append((0, 0))
        locs.append((4, 8))
        locs.append((8, 4))
        for vertex in lpg_verts_mapping[default_params_holder].itervalues():
            x = list(vertex.constraints)[0].x
            y = list(vertex.constraints)[0].y
            key = (x, y)
            locs.remove(key)

        self.assertEqual(len(locs), 0)

        verts = lpg_verts_mapping[default_params_holder].values()
        for vertex in graph.vertices:
            self.assertIn(vertex, verts)
Exemple #7
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])
    def test_added_pre_res(self):
        machine = virtual_machine(width=12, height=12, with_wrap_arounds=True)

        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}

        # 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()

        # create pre res
        sdram_requirements = {machine.get_chip_at(2, 2): 30000,
                              machine.get_chip_at(7, 7): 50000}
        core_requirements = {machine.get_chip_at(3, 3): 2}

        sdrams = list()
        cores = list()
        for chip in sdram_requirements:
            sdrams.append(SpecificChipSDRAMResource(
                chip, ConstantSDRAM(sdram_requirements[chip])))
        for chip in core_requirements:
            cores.append(CoreResource(chip, core_requirements[chip]))
        pre_pre_res = PreAllocatedResourceContainer(
            core_resources=cores, specific_sdram_usage=sdrams)

        # run  pre allocator
        pre_alloc = PreAllocateResourcesForLivePacketGatherers()
        pre_res = pre_alloc(
            live_packet_gatherer_parameters=live_packet_gatherers,
            machine=machine, pre_allocated_resources=pre_pre_res)

        locs = list()
        locs.append((0, 0))
        locs.append((4, 8))
        locs.append((8, 4))
        locs.append((2, 2))
        locs.append((7, 7))

        # verify sdram
        sdrams = pre_res.specific_sdram_usage
        for sdram in sdrams:
            locs.remove((sdram.chip.x, sdram.chip.y))
            if sdram.sdram_usage.get_total_sdram(0) != \
                    LivePacketGatherMachineVertex.get_sdram_usage():
                self.assertIn(sdram.chip.x, (2, 7))
                self.assertIn(sdram.chip.y, (2, 7))
                self.assertEqual(sdram.chip.x, sdram.chip.y)
                if sdram.chip.x == 2 and sdram.chip.y == 2:
                    self.assertEqual(sdram.sdram_usage.get_total_sdram(0),
                                     30000)
                elif sdram.chip.x == 7 and sdram.chip.y == 7:
                    self.assertEqual(sdram.sdram_usage.get_total_sdram(0),
                                     50000)
        self.assertEqual(len(locs), 0)

        locs = list()
        locs.append((0, 0))
        locs.append((4, 8))
        locs.append((8, 4))
        locs.append((3, 3))

        # verify cores
        cores = pre_res.core_resources
        for core in cores:
            locs.remove((core.chip.x, core.chip.y))
            if core.n_cores != 1:
                self.assertEqual(core.chip.x, 3)
                self.assertEqual(core.chip.y, 3)
                self.assertEqual(core.n_cores, 2)
        self.assertEqual(len(locs), 0)

        # verify specific cores
        self.assertEqual(len(pre_res.specific_core_resources), 0)
Exemple #9
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])
Exemple #10
0
    def update_live_packet_gather_tracker(
            vertex_to_record_from,
            lpg_label,
            port=None,
            hostname=None,
            tag=None,
            strip_sdp=True,
            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,
            partition_ids=None):
        """ Add an edge from a vertex to the live packet gatherer, builds as\
            needed and has all the parameters for the creation of the live\
            packet gatherer if needed.

        :param vertex_to_record_from:
        :type vertex_to_record_from:
            ~pacman.model.graphs.application.ApplicationVertex or
            ~pacman.model.graphs.machine.MachineVertex
        :param str lpg_label:
        :param int port:
        :param str hostname:
        :param int tag:
        :param bool strip_sdp:
        :param bool use_prefix:
        :param int key_prefix:
        :param ~spinnman.messages.eieio.EIEIOPrefix prefix_type:
        :param ~spinnman.messages.eieio.EIEIOType message_type:
        :param int right_shift:
        :param bool payload_as_time_stamps:
        :param bool use_payload_prefix:
        :param int payload_prefix:
        :param int payload_right_shift:
        :param int number_of_packets_sent_per_time_step:
        :param list(str) partition_ids:
        """
        # pylint: disable=too-many-arguments, too-many-locals
        params = LivePacketGatherParameters(
            port=port,
            hostname=hostname,
            tag=tag,
            strip_sdp=strip_sdp,
            use_prefix=use_prefix,
            key_prefix=key_prefix,
            prefix_type=prefix_type,
            message_type=message_type,
            right_shift=right_shift,
            payload_prefix=payload_prefix,
            payload_as_time_stamps=payload_as_time_stamps,
            use_payload_prefix=use_payload_prefix,
            payload_right_shift=payload_right_shift,
            number_of_packets_sent_per_time_step=(
                number_of_packets_sent_per_time_step),
            label=lpg_label)

        # add to the tracker
        get_simulator().add_live_packet_gatherer_parameters(
            params, vertex_to_record_from, partition_ids)
Exemple #11
0
    def test_local_verts_go_to_local_lpgs_app_graph(self):
        machine = virtual_machine(width=12, height=12)
        app_graph = ApplicationGraph("Test")
        graph = MachineGraph("Test", app_graph)

        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
        for chip in machine.ethernet_connected_chips:
            new_params = dict(default_params)
            vertex = LivePacketGather(
                LivePacketGatherParameters(**new_params))
            app_graph.add_vertex(vertex)
            vertex_slice = None
            resources_required = vertex.get_resources_used_by_atoms(
                vertex_slice)
            mac_vertex = vertex.create_machine_vertex(
                vertex_slice, resources_required)
            graph.add_vertex(mac_vertex)
            placements.add_placement(
                Placement(x=chip.x, y=chip.y, p=2, vertex=mac_vertex))
            live_packet_gatherers_to_vertex_mapping[
                default_params_holder][chip.x, chip.y] = mac_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 = SimpleTestVertex(1)
            app_graph.add_vertex(vertex)
            vertex_slice = Slice(0, 0)
            resources_required = vertex.get_resources_used_by_atoms(
                vertex_slice)
            mac_vertex = vertex.create_machine_vertex(
                vertex_slice, resources_required)
            graph.add_vertex(mac_vertex)
            partition_ids = ["EVENTS"]
            live_packet_gatherers[default_params_holder].append(
                (vertex, partition_ids))
            verts_expected[eth_x, eth_y].append(mac_vertex)
            placements.add_placement(
                Placement(x=x, y=y, p=5, vertex=mac_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=app_graph)

        # 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])

        # check app graph
        for chip in machine.ethernet_connected_chips:
            app_verts_expected = [
                vert.app_vertex for vert in verts_expected[chip.x, chip.y]]
            lpg_machine = live_packet_gatherers_to_vertex_mapping[
                default_params_holder][chip.x, chip.y]
            for edge in app_graph.get_edges_ending_at_vertex(
                    lpg_machine.app_vertex):
                self.assertIn(edge.pre_vertex, app_verts_expected)
Exemple #12
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])
    def test_that_6_lpgs_are_generated_2_on_each_eth_chip_app_graph(self):
        machine = virtual_machine(width=12, height=12)
        app_graph = ApplicationGraph("Test")
        graph = MachineGraph("Test", app_graph)

        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()

        # and special LPG on Ethernet connected chips
        chip_special = dict()
        for chip in machine.ethernet_connected_chips:
            extended = dict(default_params)
            extended['board_address'] = chip.ip_address
            default_params_holder2 = LivePacketGatherParameters(**extended)
            live_packet_gatherers[default_params_holder2] = list()
            chip_special[(chip.x, chip.y)] = default_params_holder2

        # run edge inserter that should go boom
        edge_inserter = InsertLivePacketGatherersToGraphs()
        lpg_verts_mapping = edge_inserter(
            live_packet_gatherer_parameters=live_packet_gatherers,
            machine=machine, machine_graph=graph, application_graph=app_graph)

        self.assertEqual(len(lpg_verts_mapping[default_params_holder]), 3)

        for eth_chip in chip_special:
            params = chip_special[eth_chip]
            self.assertEqual(len(lpg_verts_mapping[params]), 1)
            vertex = lpg_verts_mapping[params][eth_chip]
            self.assertEqual(eth_chip[0], list(vertex.constraints)[0].x)
            self.assertEqual(eth_chip[1], list(vertex.constraints)[0].y)

        verts = list(lpg_verts_mapping[default_params_holder].values())
        for params in chip_special.values():
            verts.extend(lpg_verts_mapping[params].values())

        for vertex in graph.vertices:
            self.assertIn(vertex, verts)

        app_verts = set()
        for vertex in verts:
            app_vertex = vertex.app_vertex
            self.assertIsInstance(app_vertex, ApplicationVertex)
            app_verts.add(app_vertex)
        self.assertEqual(len(app_verts), 6)
Exemple #14
0
    def test_one_lpg_params_and_3_specific(self):
        machine = VirtualMachine(width=12, height=12, with_wrap_arounds=True)

        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()

        # and special LPG on Ethernet connected chips
        index = 1
        for chip in machine.ethernet_connected_chips:
            extended['label'] = "test{}".format(index)
            extended['board_address'] = chip.ip_address
            default_params_holder2 = LivePacketGatherParameters(**extended)
            live_packet_gatherers[default_params_holder2] = list()

        pre_alloc = PreAllocateResourcesForLivePacketGatherers()
        pre_res = pre_alloc(
            live_packet_gatherer_parameters=live_packet_gatherers,
            machine=machine)

        locs = list()
        locs.append((0, 0))
        locs.append((4, 8))
        locs.append((8, 4))

        # verify sdram
        sdrams = pre_res.specific_sdram_usage
        for sdram in sdrams:
            locs.remove((sdram.chip.x, sdram.chip.y))
            self.assertEqual(
                sdram.sdram_usage,
                LivePacketGatherMachineVertex.get_sdram_usage() * 2)
        self.assertEqual(len(locs), 0)

        locs = dict()
        locs[(0, 0)] = 0
        locs[(4, 8)] = 0
        locs[(8, 4)] = 0

        # verify cores
        cores = pre_res.core_resources
        for core in cores:
            locs[(core.chip.x, core.chip.y)] += core.n_cores

        for (x, y) in [(0, 0), (4, 8), (8, 4)]:
            self.assertEqual(locs[x, y], 2)

        # verify specific cores
        self.assertEqual(len(pre_res.specific_core_resources), 0)