Exemple #1
0
class TestAnalysisTool(unittest.TestCase):
    def setUp(self):
        self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1])
        self.noc.link_array_filling()

        self.message1 = Message(1, 150, 896, 0, 100, Coordinate(0, 3),
                                Coordinate(0, 1))
        self.message2 = Message(2, 150, 256, 0, 100, Coordinate(2, 0),
                                Coordinate(3, 0))
        self.message3 = Message(3, 400, 256, 0, 300, Coordinate(0, 2),
                                Coordinate(3, 0))
        self.message4 = Message(4, 600, 256, 0, 550, Coordinate(2, 0),
                                Coordinate(3, 0))
        self.message5 = Message(5, 300, 3072, 0, 250, Coordinate(0, 1),
                                Coordinate(2, 0))

        self.messages = [
            self.message1, self.message2, self.message3, self.message4,
            self.message5
        ]

        self.qinModel = QinModel(self.noc, self.messages)

        self.tdma = TDMA(self.noc, self.noc.vc_quantum)

    def test_direct_interference_set(self):
        taskset = self.qinModel.direct_interference_set(self.message3)

        self.assertEqual(taskset[0].id, 1)
        self.assertEqual(taskset[1].id, 2)

    def test_indirect_interference_set(self):
        taskset = self.qinModel.indirect_interference_set(self.message5)

        self.assertEqual(taskset[0].id, 1)
        self.assertEqual(taskset[1].id, 2)

    def test_latency_0th(self):
        self.assertEqual(self.qinModel.latency_0th(self.message1), 30)

    def test_latency_nth(self):
        self.qinModel.latency_nth(self.message5)

    def test_total_slot(self):
        self.assertEqual(self.tdma.total_slot(), 4)

    def test_tdma_latency(self):
        latency = self.tdma.latency(self.message3, self.tdma.slot_table[1])
        self.assertEqual(latency, 37)
Exemple #2
0
class TestLink(unittest.TestCase):
    def setUp(self):
        self.noc = NoC("Network-On-Chip", 3, 4, 12, [1, 1, 1, 1])
        self.noc.router_linking()

    def test_links_array(self):
        self.noc.link_array_filling()
        self.assertEqual(len(self.noc.links.keys()), 9)
        self.assertEqual(len(self.noc.links['1']), 2)
        self.assertEqual(len(self.noc.links['5']), 4)
        self.assertEqual(len(self.noc.links['2']), 3)

    def test_links_default_utilization_rate(self):
        self.noc.link_array_filling()
        self.assertEqual(self.noc.links['1']['2'], 0)
Exemple #3
0
class TestAnalysisTool(unittest.TestCase):
    def setUp(self):
        self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1])

        self.src = Coordinate(0, 0)
        self.dest = Coordinate(2, 2)
        self.message = Message(1, 12, 256, 0, 0, self.src, self.dest)
        self.packet = Packet(1, self.dest, self.message)

        self.flit = self.packet.flits[0]

        self.proc_engine = self.noc.router_matrix[0][0].proc_engine
        self.router = self.noc.router_matrix[0][0]

        self.generation = Generation()
        self.generation.set_noc(self.noc)
        self.generation.set_square_size(4)

        self.noc.link_array_filling()

    def test_is_links_equal(self):
        message1 = Message(1, 12, 256, 0, 0, Coordinate(0, 2),
                           Coordinate(2, 2))
        message2 = Message(1, 12, 256, 0, 0, Coordinate(0, 3),
                           Coordinate(3, 3))
        p1 = self.message.get_xy_path_coordinate(self.noc)
        p2 = message1.get_xy_path_coordinate(self.noc)
        p3 = message2.get_xy_path_coordinate(self.noc)

        self.assertEqual(self.generation.task_overlap(p1, p2), True)
        self.assertEqual(self.generation.task_overlap(p1, p3), False)

    def test_direction_intersection(self):
        self.assertEqual(
            len(self.generation.direction_intersection(self.message)), 0)
        self.generation.conflict_task_by_axe(self.message, 70, 40, 0)
        self.assertGreater(
            len(self.generation.direction_intersection(self.message)), 0)
Exemple #4
0
class TestConflictByAxe(unittest.TestCase):
    def setUp(self):
        self.noc = NoC("Network-On-Chip", 4, 4, 12, [1, 1, 1, 1])

        self.src = Coordinate(0, 0)
        self.dest = Coordinate(2, 2)
        self.message = Message(1, 12, 256, 0, 0, self.src, self.dest)
        self.packet = Packet(1, self.dest, self.message)

        self.flit = self.packet.flits[0]

        self.proc_engine = self.noc.router_matrix[0][0].proc_engine
        self.router = self.noc.router_matrix[0][0]

        self.generation = Generation()
        self.generation.set_noc(self.noc)
        self.generation.set_square_size(4)

        self.noc.link_array_filling()

    def test_xy_path_coordinate(self):
        link_array = self.message.get_xy_path_coordinate(self.noc)
        self.assertEqual(len(link_array), 4)
        self.assertEqual(link_array[0][0], 1)
        self.assertEqual(link_array[0][1], 2)
        self.assertEqual(link_array[3][0], 7)
        self.assertEqual(link_array[3][1], 11)

    def test_find_links_outside_interval(self):
        link_array = self.message.get_xy_path_coordinate(self.noc)

        outside_link = self.generation.find_links_outside_interval(
            link_array, 70, 30, 0)
        self.assertEqual(len(outside_link), 4)

        self.generation.add_utilization_rate_to_link(outside_link[0], 50)
        new_outside_link = self.generation.find_links_outside_interval(
            link_array, 70, 30, 0)
        self.assertEqual(len(new_outside_link), 4)

    def test_get_link_direction(self):
        link_array = self.message.get_xy_path_coordinate(self.noc)
        link = link_array.pop()

        self.assertEqual(self.generation.get_link_direction(link), 0)

    def test_task_communication_axe(self):
        link_array = self.message.get_xy_path_coordinate(self.noc)

        router_src = self.noc.get_router_coordinate_by_id(link_array[0][0])
        router_dest = self.noc.get_router_coordinate_by_id(link_array[0][1])

        router_src_1 = self.noc.get_router_coordinate_by_id(link_array[3][0])
        router_dest_1 = self.noc.get_router_coordinate_by_id(link_array[3][1])

        axe = (0 if router_src.i == router_dest.i else 1)
        self.assertEqual(axe, 0)
        axe = (0 if router_src_1.i == router_dest_1.i else 1)
        self.assertEqual(axe, 1)

    def test_generate_conflict_task_by_axe(self):
        link_array = self.message.get_xy_path_coordinate(self.noc)
        link = link_array.pop()

        router_src = self.noc.get_router_coordinate_by_id(link[0])
        router_dest = self.noc.get_router_coordinate_by_id(link[1])

        axe = (0 if router_src.i == router_dest.i else 1)

        conflict_task = self.generation.generate_conflict_task_by_axe(
            [router_src, router_dest], link, axe, 50, 0)
        # conflict task generated by the above function has the following characteristics
        # from -> to : (0,0) -> (0,1) -> (0,2) -> (0,3) : 3 links
        # has a link utilization < 30
        self.assertEqual(len(conflict_task.get_xy_path_coordinate(self.noc)),
                         3)
        self.assertLessEqual(conflict_task.get_link_utilization(), 0.3)

    def test_conflict_task_by_axe(self):
        self.generation.conflict_task_by_axe(self.message, 70, 40, 0)