예제 #1
0
    def test_partition_with_fixed_atom_constraints(self):
        """
        test a partitioning with a graph with fixed atom constraint
        """

        # Create a 2x2 machine with 10 cores per chip (so 40 cores),
        # but 1 off 2 per chip (so 19 per chip)
        n_cores_per_chip = 10
        sdram_per_chip = (n_cores_per_chip * 2) - 1
        set_config("Machine", "max_sdram_allowed_per_chip", sdram_per_chip)
        machine = virtual_machine(width=2,
                                  height=2,
                                  n_cpus_per_chip=n_cores_per_chip)

        # Create a vertex where each atom requires 1MB (default) of SDRAM
        # but which can't be subdivided lower than 2 atoms per core.
        # The vertex has 1 atom per MB of SDRAM, and so would fit but will
        # be disallowed by the fixed atoms per core constraint
        vertex = SimpleTestVertex(sdram_per_chip * machine.n_chips,
                                  max_atoms_per_core=2,
                                  constraints=[FixedVertexAtomsConstraint(2)])
        vertex.splitter = SplitterSliceLegacy()
        app_graph = ApplicationGraph("Test")
        app_graph.add_vertex(vertex)

        # Do the partitioning - this should result in an error
        with self.assertRaises(PacmanException):
            splitter_partitioner(app_graph, machine, 3000)
    def test_routing(self):
        graph = MachineGraph("Test")
        set_config("Machine", "down_chips", "1,2:5,4:3,3")
        machine = virtual_machine(8, 8)
        placements = Placements()
        vertices = list()

        for chip in machine.chips:
            for processor in chip.processors:
                if not processor.is_monitor:
                    vertex = SimpleMachineVertex(resources=ResourceContainer())
                    graph.add_vertex(vertex)
                    placements.add_placement(
                        Placement(vertex, chip.x, chip.y,
                                  processor.processor_id))
                    vertices.append(vertex)

        for vertex in vertices:
            graph.add_outgoing_edge_partition(
                MulticastEdgePartition(identifier="Test", pre_vertex=vertex))
            for vertex_to in vertices:
                graph.add_edge(MachineEdge(vertex, vertex_to), "Test")

        routing_paths = ner_route_traffic_aware(graph, machine, placements)

        for vertex in vertices:
            vertices_reached = set()
            queue = deque()
            seen_entries = set()
            placement = placements.get_placement_of_vertex(vertex)
            partition = graph.get_outgoing_edge_partition_starting_at_vertex(
                vertex, "Test")
            entry = routing_paths.get_entry_on_coords_for_edge(
                partition, placement.x, placement.y)
            self.assertEqual(entry.incoming_processor, placement.p)
            queue.append((placement.x, placement.y))
            while len(queue) > 0:
                x, y = queue.pop()
                entry = routing_paths.get_entry_on_coords_for_edge(
                    partition, x, y)
                self.assertIsNotNone(entry)
                chip = machine.get_chip_at(x, y)
                for p in entry.processor_ids:
                    self.assertIsNotNone(chip.get_processor_with_id(p))
                    vertex_found = placements.get_vertex_on_processor(x, y, p)
                    vertices_reached.add(vertex_found)
                seen_entries.add((x, y))
                for link_id in entry.link_ids:
                    link = chip.router.get_link(link_id)
                    self.assertIsNotNone(link)
                    dest_x, dest_y = link.destination_x, link.destination_y
                    if (dest_x, dest_y) not in seen_entries:
                        queue.append((dest_x, dest_y))

            for vertex_to in vertices:
                self.assertIn(vertex_to, vertices_reached)
    def test_big(self):
        set_config("Mapping", "router_table_compress_as_far_as_possible", True)
        class_file = sys.modules[self.__module__].__file__
        path = os.path.dirname(os.path.abspath(class_file))
        j_router = os.path.join(path, "malloc_hard_routing_tables.json.gz")
        original_tables = from_json(j_router)

        mundy_compressor = OrderedCoveringCompressor()
        pre_compressor = UnorderedPairCompressor()

        start = time.time()
        mundy_tables = mundy_compressor(original_tables, True)
        mundy_time = time.time()
        pre_tables = pre_compressor(original_tables, True)
        pre_time = time.time()
        both_tables = mundy_compressor(pre_tables, True)
        both_time = time.time()
        for original in original_tables:
            org_routes = set()
            for entry in original.multicast_routing_entries:
                org_routes.add(entry.spinnaker_route)
            mundy = mundy_tables.get_routing_table_for_chip(
                original.x, original.y)
            mundy_routes = set()
            for entry in mundy.multicast_routing_entries:
                mundy_routes.add(entry.spinnaker_route)
            compare_tables(original, mundy)
            pre = pre_tables.get_routing_table_for_chip(original.x, original.y)
            pre_routes = set()
            for entry in pre.multicast_routing_entries:
                pre_routes.add(entry.spinnaker_route)
            compare_tables(original, pre)
            both = both_tables.get_routing_table_for_chip(
                original.x, original.y)
            both_routes = set()
            for entry in both.multicast_routing_entries:
                both_routes.add(entry.spinnaker_route)
            compare_tables(original, both)

            print("org:", original.number_of_entries,
                  len(org_routes), "mundy:", mundy.number_of_entries,
                  len(mundy_routes), "pre:", pre.number_of_entries,
                  len(pre_routes), "both:", both.number_of_entries,
                  len(both_routes))
        print("Mundy", mundy_time - start)
        print("Unordered", pre_time - mundy_time)
        print("Mundy after Unordered", both_time - pre_time)
def test_all_working(width, height, with_down_links, with_down_chips):
    unittest_setup()
    temp_machine = virtual_machine(width=width, height=height)
    down_links = None
    if with_down_links:
        down_links = set()
        for ethernet_chip in temp_machine.ethernet_connected_chips:
            down_links.add((ethernet_chip.x + 1, ethernet_chip.y, 5))
            down_links.add((ethernet_chip.x, ethernet_chip.y + 1, 3))
        down_str = ":".join([f"{x},{y},{link}" for x, y, link in down_links])
        set_config("Machine", "down_links", down_str)
    down_chips = None
    if with_down_chips:
        down_chips = set(
            (ethernet_chip.x + 1, ethernet_chip.y + 1)
            for ethernet_chip in temp_machine.ethernet_connected_chips)
        down_str = ":".join([f"{x},{y}" for x, y in down_chips])
        set_config("Machine", "down_chips", down_str)
    _check_setup(width, height)
예제 #5
0
 def setUp(self):
     self.original_tables = MulticastRoutingTables()
     original_table = UnCompressedMulticastRoutingTable(x=0, y=0)
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b0000, 0b1111, [1, 2], [], False))
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b0001, 0b1111, [0], [], False))
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b0101, 0b1111, [4], [], False))
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b1000, 0b1111, [1, 2], [], False))
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b1001, 0b1111, [0], [], False))
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b1110, 0b1111, [4], [], False))
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b1100, 0b1111, [1, 2], [], False))
     original_table.add_multicast_routing_entry(
         MulticastRoutingEntry(0b0010, 0b1011, [4, 5], [], False))
     self.original_tables.add_routing_table(original_table)
     unittest_setup()
     set_config("Mapping", "router_table_compress_as_far_as_possible", True)
예제 #6
0
def hacked_receive_chip_info(self, scp_read_chip_info_response):
    chip_info = scp_read_chip_info_response.chip_info
    self._chip_info[chip_info.x, chip_info.y] = chip_info

    # Hack to test ignores
    if (chip_info.x == 8 and chip_info.y == 4):
        # hack the config to include an actual ip address used
        set_config(
            "Machine", "down_cores", f"3,0,-4:99,99,2:2,2,-19:3,3,4,127.0.0.1:"
            f"2,2,-10,{chip_info.ethernet_ip_address}:"
            f"2,2,-9,{chip_info.ethernet_ip_address}:"
            f"2,2,4,{chip_info.ethernet_ip_address}")
        set_config(
            "Machine", "down_chips", f"6,7:3,3,127.0.0.1:"
            f"3,3,{chip_info.ethernet_ip_address}")
        set_config(
            "Machine", "down_links", f"3,3,4,127.0.0.1:5,5,2:"
            f"4,4,1,{chip_info.ethernet_ip_address}")
예제 #7
0
    json_obj = to_json(bad)
    # dump to json file
    with open("routing_tables_zoned_bad1.json", "w") as f:
        json.dump(json_obj, f)
    json_obj = to_json(good)
    # dump to json file
    with open("routing_tables_zoned_2000.json", "w") as f:
        json.dump(json_obj, f)
    original_tables = bad

MUNDY = True
PRE = True
PAIR = True
# Hack to stop it throwing a wobly for too many entries
Machine.ROUTER_ENTRIES = 50000
set_config("Mapping", "router_table_compress_as_far_as_possible", True)

if MUNDY:
    start = time.time()
    mundy_tables = ordered_covering_compressor(original_tables)
mundy_time = time.time()
if PRE:
    pre_tables = pair_compressor(original_tables, ordered=False)
pre_time = time.time()
if MUNDY and PRE:
    both_tables = ordered_covering_compressor(pre_tables)
both_time = time.time()
if PAIR:
    pair_tables = pair_compressor(original_tables)
pair_time = time.time()
for original in original_tables:
def test_unreachable():
    unittest_setup()
    set_config("Machine", "down_chips", "0,2:1,3:1,4")
    with pytest.raises(PacmanRoutingException):
        _check_setup(8, 8)
예제 #9
0
 def setUp(self):
     unittest_setup()
     set_config("Mapping", "router_table_compress_as_far_as_possible", True)