コード例 #1
0
    def test_shmu_breaking_and_restore(self):
        ag_4_test = copy.deepcopy(generate_ag(logging=None))
        shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
        shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
        for node in shmu_4_test.SHM.nodes():
            shmu_4_test.break_node(node, False)
            self.assertEqual(shmu_4_test.SHM.node[node]['NodeHealth'], False)

            for Turn in shmu_4_test.SHM.node[node]['TurnsHealth']:
                shmu_4_test.break_turn(node, Turn, False)
                self.assertEqual(
                    shmu_4_test.SHM.node[node]['TurnsHealth'][Turn], False)

        for link in shmu_4_test.SHM.edges():
            shmu_4_test.break_link(link, False)
            self.assertEqual(
                shmu_4_test.SHM.edge[link[0]][link[1]]['LinkHealth'], False)
        # testing Restore
        for node in shmu_4_test.SHM.nodes():
            shmu_4_test.restore_broken_node(node, False)
            self.assertEqual(shmu_4_test.SHM.node[node]['NodeHealth'], True)

            for turn in shmu_4_test.SHM.node[node]['TurnsHealth']:
                shmu_4_test.restore_broken_turn(node, turn, False)
                self.assertEqual(
                    shmu_4_test.SHM.node[node]['TurnsHealth'][turn], True)

        for link in shmu_4_test.SHM.edges():
            shmu_4_test.restore_broken_link(link, False)
            self.assertEqual(
                shmu_4_test.SHM.edge[link[0]][link[1]]['LinkHealth'], True)
        del ag_4_test
        del shmu_4_test
コード例 #2
0
    def test_how_many_paths_from_source(self):
        initial_config_ag = deepcopy(Config.ag)
        initial_turn_model = Config.UsedTurnModel
        initial_routing_type = Config.RotingType

        Config.ag.type = "Generic"
        Config.ag.topology = "2DMesh"
        Config.ag.x_size = 3
        Config.ag.y_size = 3
        Config.ag.z_size = 1

        turn_model = PackageFile.XY_TurnModel
        Config.UsedTurnModel = deepcopy(turn_model)
        Config.TurnsHealth = deepcopy(Config.setup_turns_health())
        ag_4_test = deepcopy(generate_ag(logging=None))
        shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
        shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
        noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False)
        for source_node in ag_4_test.nodes():
            for destination_node in ag_4_test.nodes():
                if source_node != destination_node:
                    self.assertEqual(how_many_paths_from_source(noc_rg, source_node, destination_node), 1)

        Config.ag = deepcopy(initial_config_ag)
        Config.UsedTurnModel = initial_turn_model
        Config.TurnsHealth = deepcopy(Config.setup_turns_health())
        Config.RotingType = initial_routing_type
コード例 #3
0
 def test_shmu_aging(self):
     ag_4_test = copy.deepcopy(generate_ag(logging=None))
     shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
     shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
     for Node in shmu_4_test.SHM.nodes():
         shmu_4_test.introduce_aging(Node, 0.5, False)
         self.assertEqual(shmu_4_test.SHM.node[Node]['NodeSpeed'], 50)
         shmu_4_test.introduce_aging(Node, 0.5, False)
         self.assertEqual(shmu_4_test.SHM.node[Node]['NodeSpeed'], 25)
     del ag_4_test
     del shmu_4_test
コード例 #4
0
    def test_return_healthy_nodes(self):
        ag_4_test = copy.deepcopy(generate_ag(logging=None))
        shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
        shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)

        healthy_nodes = copy.deepcopy(ag_4_test.nodes())
        for node in ag_4_test.nodes():
            if random.choice(['Healthy', 'Faulty']) == 'Faulty':
                healthy_nodes.remove(node)
                shmu_4_test.break_node(node, False)

        test_healthy_nodes = return_healthy_nodes(ag_4_test, shmu_4_test.SHM)
        self.assertEqual(test_healthy_nodes, healthy_nodes)
        del ag_4_test
        del shmu_4_test
コード例 #5
0
    def test_update_ag_regions(self):

        # taking a copy of the Config
        temp_critical_region = copy.deepcopy(Config.CriticalRegionNodes)
        temp_gnc_region = copy.deepcopy(Config.GateToNonCritical)
        temp_gc_region = copy.deepcopy(Config.GateToCritical)
        temp_ag_x = Config.ag.x_size
        temp_ag_y = Config.ag.y_size
        temp_ag_z = Config.ag.z_size

        # setting up the Config
        Config.ag.x_size = 5
        Config.ag.y_size = 5
        Config.ag.z_size = 1

        Config.CriticalRegionNodes = [16, 17, 21, 22, 23, 28, 29]
        Config.GateToNonCritical = [15, 27]
        Config.GateToCritical = [20]

        ag_4_test = copy.deepcopy(generate_ag(logging=None))
        self.assertEqual(len(ag_4_test.nodes()), Config.ag.x_size*Config.ag.y_size*Config.ag.z_size)

        update_ag_regions(ag_4_test)

        for node in ag_4_test.nodes():
            if node in Config.CriticalRegionNodes:
                self.assertEqual(ag_4_test.node[node]['Region'], 'H')
            elif node in Config.GateToCritical:
                self.assertEqual(ag_4_test.node[node]['Region'], 'GH')
            elif node in Config.GateToNonCritical:
                self.assertEqual(ag_4_test.node[node]['Region'], 'GNH')
            else:
                self.assertEqual(ag_4_test.node[node]['Region'], 'L')

        # return to previous Config
        Config.CriticalRegionNodes = copy.deepcopy(temp_critical_region)
        Config.GateToNonCritical = copy.deepcopy(temp_gnc_region)
        Config.GateToCritical = copy.deepcopy(temp_gc_region)

        Config.ag.x_size = temp_ag_x
        Config.ag.y_size = temp_ag_y
        Config.ag.z_size = temp_ag_z
        del ag_4_test
コード例 #6
0
 def test_random_darkness_return_active_nodes(self):
     # copy the config
     config_darkness = Config.DarkSiliconPercentage
     ag_4_test = copy.deepcopy(generate_ag(logging=None))
     for i in range(1, 100):
         Config.DarkSiliconPercentage = i
         random_darkness(ag_4_test)
         num_of_dark_nodes = 0
         for node in ag_4_test.nodes():
             if ag_4_test.node[node]['PE'].dark:
                 num_of_dark_nodes += 1
         self.assertEqual(num_of_dark_nodes, ceil(len(ag_4_test.nodes())*i/100))
         active_nodes = return_active_nodes(ag_4_test)
         self.assertEqual(len(ag_4_test.nodes())-num_of_dark_nodes, len(active_nodes))
         # clean the AG
         for node in ag_4_test.nodes():
             ag_4_test.node[node]['PE'].dark = False
     del ag_4_test
     # return to previous config
     Config.DarkSiliconPercentage = config_darkness
コード例 #7
0
    def test_clear_reachability_calculations(self):
        initial_config_ag = deepcopy(Config.ag)
        initial_turn_model = Config.UsedTurnModel
        initial_routing_type = Config.RotingType

        Config.ag.type = "Generic"
        Config.ag.topology = "2DMesh"
        Config.ag.x_size = 3
        Config.ag.y_size = 3
        Config.ag.z_size = 1

        ag_4_test = deepcopy(generate_ag(logging=None))
        clear_reachability_calculations(ag_4_test)
        for node in ag_4_test.nodes():
            for port in ag_4_test.node[node]['Router'].unreachable:
                self.assertEqual(ag_4_test.node[node]['Router'].unreachable[port], {})
        del ag_4_test

        Config.ag = deepcopy(initial_config_ag)
        Config.UsedTurnModel = initial_turn_model
        Config.TurnsHealth = deepcopy(Config.setup_turns_health())
        Config.RotingType = initial_routing_type
コード例 #8
0
 def test_apply_initial_faults(self):
     # todo: generate some random faults and put them in Config and then return to normal
     ag_4_test = copy.deepcopy(generate_ag(logging=None))
     shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
     shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
     SHMU_Functions.apply_initial_faults(shmu_4_test)
     for broken_link in Config.ListOfBrokenLinks:
         self.assertEqual(
             shmu_4_test.SHM.edge[broken_link[0]][broken_link[1]]
             ['LinkHealth'], False)
     for router_with_broken_turn in Config.ListOfBrokenTurns:
         broken_turn = Config.ListOfBrokenTurns[router_with_broken_turn]
         self.assertEqual(
             shmu_4_test.SHM.node[router_with_broken_turn]['TurnsHealth']
             [broken_turn], False)
     for broken_node in Config.ListOfBrokenPEs:
         self.assertEqual(shmu_4_test.SHM.node[broken_node]['NodeHealth'],
                          False)
     for aged_pe in Config.ListOfAgedPEs:
         self.assertEqual(shmu_4_test.SHM.node[aged_pe]['NodeSpeed'],
                          Config.ListOfAgedPEs[aged_pe])
     del ag_4_test
     del shmu_4_test
コード例 #9
0
    def test_is_destination_reachable_from_source(self):
        initial_config_ag = deepcopy(Config.ag)
        initial_turn_model = Config.UsedTurnModel
        initial_routing_type = Config.RotingType

        Config.ag.type = "Generic"
        Config.ag.topology = "2DMesh"
        Config.ag.x_size = 3
        Config.ag.y_size = 3
        Config.ag.z_size = 1

        for turn_model in PackageFile.routing_alg_list_2d:
            Config.UsedTurnModel = deepcopy(turn_model)
            Config.TurnsHealth = deepcopy(Config.setup_turns_health())
            ag_4_test = deepcopy(generate_ag(logging=None))
            shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
            shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
            noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False)
            for source_node in ag_4_test.nodes():
                for destination_node in ag_4_test.nodes():
                    if source_node != destination_node:
                        self.assertEqual(is_destination_reachable_from_source(noc_rg, source_node, destination_node),
                                         True)
                        s_x, s_y, s_z = return_node_location(source_node)
                        d_x, d_y, d_z = return_node_location(destination_node)
                        # is_destination_reachable_via_port checks output ports only
                        self.assertEqual(is_destination_reachable_via_port(noc_rg, source_node, 'L',
                                                                           destination_node, False), False)
                        if turn_model == PackageFile.XY_TurnModel:
                            if s_x > d_x:
                                self.assertEqual(is_destination_reachable_via_port(noc_rg, source_node, 'W',
                                                                                   destination_node, False), True)
                            if s_x < d_x:
                                self.assertEqual(is_destination_reachable_via_port(noc_rg, source_node, 'E',
                                                                                   destination_node, False), True)
                            if s_x == d_x:
                                if s_y < d_y:
                                    self.assertEqual(is_destination_reachable_via_port(noc_rg, source_node, 'N',
                                                                                       destination_node, False), True)
                                else:
                                    self.assertEqual(is_destination_reachable_via_port(noc_rg, source_node, 'S',
                                                                                       destination_node, False), True)
            del ag_4_test
            del shmu_4_test
            del noc_rg

        Config.ag.type = "Generic"
        Config.ag.topology = "3DMesh"
        Config.ag.x_size = 3
        Config.ag.y_size = 3
        Config.ag.z_size = 3
        Config.RotingType = "MinimalPath"

        for turn_model in PackageFile.routing_alg_list_3d:
            Config.UsedTurnModel = deepcopy(turn_model)
            Config.TurnsHealth = deepcopy(Config.setup_turns_health())
            ag_4_test = deepcopy(generate_ag(logging=None))
            shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
            shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
            noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test, turn_model, False, False)
            for source_node in ag_4_test.nodes():
                for destination_node in ag_4_test.nodes():
                    if source_node != destination_node:
                        self.assertEqual(is_destination_reachable_from_source(noc_rg, source_node, destination_node),
                                         True)
                    # todo: check is_destination_reachable_via_port
            del ag_4_test
            del shmu_4_test
            del noc_rg

        Config.ag = deepcopy(initial_config_ag)
        Config.UsedTurnModel = initial_turn_model
        Config.TurnsHealth = deepcopy(Config.setup_turns_health())
        Config.RotingType = initial_routing_type
コード例 #10
0
    def test_routing_functions(self):
        initial_config_ag = deepcopy(Config.ag)
        initial_turn_model = Config.UsedTurnModel
        initial_routing_type = Config.RotingType
        Config.ag.type = "Generic"
        Config.ag.topology = "2DMesh"
        Config.ag.x_size = 3
        Config.ag.y_size = 3
        Config.ag.z_size = 1

        for turn_model in PackageFile.routing_alg_list_2d:
            Config.UsedTurnModel = deepcopy(turn_model)
            Config.TurnsHealth = deepcopy(Config.setup_turns_health())
            ag_4_test = deepcopy(generate_ag(logging=None))
            shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit(
            )
            shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
            noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test,
                                              turn_model, False, False)
            self.assertEqual(check_deadlock_freeness(noc_rg), True)
            if turn_model in [
                    PackageFile.XY_TurnModel, PackageFile.YX_TurnModel
            ]:
                if turn_model == PackageFile.XY_TurnModel:
                    self.assertEqual(return_turn_model_name(turn_model), '0')
                else:
                    self.assertEqual(return_turn_model_name(turn_model), '13')
                self.assertEqual(
                    degree_of_adaptiveness(ag_4_test, noc_rg, False) / 72, 1)
                self.assertEqual(
                    extended_degree_of_adaptiveness(ag_4_test, noc_rg, False) /
                    72, 1)
            del ag_4_test
            del shmu_4_test

        Config.ag.type = "Generic"
        Config.ag.topology = "3DMesh"
        Config.ag.x_size = 3
        Config.ag.y_size = 3
        Config.ag.z_size = 3
        Config.RotingType = "NonMinimalPath"

        for turn_model in PackageFile.routing_alg_list_3d:
            Config.UsedTurnModel = deepcopy(turn_model)
            Config.TurnsHealth = deepcopy(Config.setup_turns_health())
            ag_4_test = deepcopy(generate_ag(logging=None))
            shmu_4_test = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit(
            )
            shmu_4_test.setup_noc_shm(ag_4_test, Config.TurnsHealth, False)
            noc_rg = generate_noc_route_graph(ag_4_test, shmu_4_test,
                                              turn_model, False, False)
            self.assertEqual(check_deadlock_freeness(noc_rg),
                             True,
                             msg="Current Ralgo %s" % turn_model)
            if turn_model == PackageFile.XYZ_TurnModel:
                self.assertEqual(return_turn_model_name(turn_model), "3d_XYZ")
                self.assertEqual(
                    degree_of_adaptiveness(ag_4_test, noc_rg, False) / 702, 1)
                self.assertEqual(
                    extended_degree_of_adaptiveness(ag_4_test, noc_rg, False) /
                    702, 1)
            if turn_model == PackageFile.NegativeFirst3D_TurnModel:
                self.assertEqual(return_turn_model_name(turn_model),
                                 "3d_NegFirst")
            del ag_4_test
            del shmu_4_test
            del noc_rg

        Config.ag = deepcopy(initial_config_ag)
        Config.UsedTurnModel = initial_turn_model
        Config.TurnsHealth = deepcopy(Config.setup_turns_health())
        Config.RotingType = initial_routing_type