Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 3
0
def init():
    """
    Uses SoCDep2 to generate a routing graph

    Returns:
        Routing graph
    """
    misc.generate_file_directories()
    turns_health_2d_network = {
        "N2W": True,
        "N2E": True,
        "S2W": True,
        "S2E": True,
        "W2N": True,
        "W2S": True,
        "E2N": True,
        "E2S": True
    }

    Config.ag.topology = '2DMesh'
    Config.ag.x_size = 4
    Config.ag.y_size = 4
    Config.ag.z_size = 1
    Config.RoutingType = 'MinimalPath'

    ag = copy.deepcopy(generate_ag(logging=None, report=False))
    shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit()
    shmu.setup_noc_shm(ag, copy.deepcopy(turns_health_2d_network), False)

    noc_rg = copy.deepcopy(
        Routing.generate_noc_route_graph(ag, shmu, PackageFile.XY_TurnModel,
                                         False, False))

    return noc_rg
Ejemplo n.º 4
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
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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
Ejemplo n.º 8
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