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
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) 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
def initialize_system_DoS(logging): """ Generates the Task graph, Architecture Graph, System Health Monitoring Unit, NoC routing graph(s) and Test Task Graphs and does the mapping and scheduling and returns to the user the initial system :param logging: logging file :return: ag, shmu, noc_rg """ #################################################################### ag = copy.deepcopy(AG_Functions.generate_ag(logging)) AG_Functions.update_ag_regions(ag) AG_Functions.random_darkness(ag) if Config.EnablePartitioning: AG_Functions.setup_network_partitioning(ag) if Config.FindOptimumAG: Arch_Graph_Reports.draw_ag(ag, "AG_Full") else: Arch_Graph_Reports.draw_ag(ag, "AG") #################################################################### Config.setup_turns_health() shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, Config.TurnsHealth, True) # Here we are injecting initial faults of the system: we assume these fault # information is obtained by post manufacturing system diagnosis SHMU_Functions.apply_initial_faults(shmu) if Config.viz.shm: SHMU_Reports.draw_shm(shmu.SHM) SHMU_Reports.draw_temp_distribution(shmu.SHM) # SHM_Reports.report_noc_shm() #################################################################### routing_graph_start_time = time.time() noc_rg = copy.deepcopy(Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, Config.DebugInfo, Config.DebugDetails)) Routing_Functions.check_deadlock_freeness(noc_rg) print ("\033[92mTIME::\033[0m ROUTING GRAPH GENERATION TOOK: " + str(round(time.time()-routing_graph_start_time))+" SECONDS") # Some visualization... if Config.viz.rg: RoutingGraph_Reports.draw_rg(noc_rg) return ag, shmu, noc_rg
def initialize_system_DoS(logging): """ Generates the Task graph, Architecture Graph, System Health Monitoring Unit, NoC routing graph(s) and Test Task Graphs and does the mapping and scheduling and returns to the user the initial system :param logging: logging file :return: ag, shmu, noc_rg """ #################################################################### ag = copy.deepcopy(AG_Functions.generate_ag(logging)) AG_Functions.update_ag_regions(ag) AG_Functions.random_darkness(ag) if Config.EnablePartitioning: AG_Functions.setup_network_partitioning(ag) if Config.FindOptimumAG: Arch_Graph_Reports.draw_ag(ag, "AG_Full") else: Arch_Graph_Reports.draw_ag(ag, "AG") #################################################################### Config.setup_turns_health() shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, Config.TurnsHealth, True) # Here we are injecting initial faults of the system: we assume these fault # information is obtained by post manufacturing system diagnosis SHMU_Functions.apply_initial_faults(shmu) if Config.viz.shm: SHMU_Reports.draw_shm(shmu.SHM) SHMU_Reports.draw_temp_distribution(shmu.SHM) # SHM_Reports.report_noc_shm() #################################################################### routing_graph_start_time = time.time() noc_rg = copy.deepcopy(Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, Config.DebugInfo, Config.DebugDetails)) Routing_Functions.check_deadlock_freeness(noc_rg) print("\033[92mTIME::\033[0m ROUTING GRAPH GENERATION TOOK: " + str(round(time.time()-routing_graph_start_time))+" SECONDS") # Some visualization... if Config.viz.rg: RoutingGraph_Reports.draw_rg(noc_rg) return ag, shmu, noc_rg
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
def update_config(config_file_path): try: config_file = open(config_file_path, 'r') config_file.close() except IOError: print('CAN NOT OPEN config_file') config = ConfigParser.ConfigParser(allow_no_value=True) config.read(config_file_path) # ------------------------------------------------ # Program_Config # ------------------------------------------------ Config.enable_simulator = config.getboolean("Program_Config", "enable_simulator") Config.ProgramRunTime = config.getint("Program_Config", "ProgramRunTime") Config.DebugInfo = config.getboolean("Program_Config", "DebugInfo") Config.DebugDetails = config.getboolean("Program_Config", "DebugDetails") Config.TestMode = config.getboolean("Program_Config", "TestMode") Config.MemoryProfiler = config.getboolean("Program_Config", "MemoryProfiler") Config.EventDrivenFaultInjection = config.getboolean( "Program_Config", "EventDrivenFaultInjection") Config.fault_injection_method = config.get("Program_Config", "fault_injection_method") Config.fault_injection_file = config.get("Program_Config", "fault_injection_file") # ------------------------------------------------ # TG_Config # ------------------------------------------------ Config.tg.type = config.get("TG_Config", "TG_Type") Config.tg.num_of_tasks = config.getint("TG_Config", "NumberOfTasks") Config.tg.num_of_critical_tasks = config.getint("TG_Config", "NumberOfCriticalTasks") Config.tg.num_of_edges = config.getint("TG_Config", "NumberOfEdges") Config.tg.wcet_range = config.getint("TG_Config", "WCET_Range") Config.tg.edge_weight_range = config.getint("TG_Config", "EdgeWeightRange") Config.tg.release_range = config.getint( "TG_Config", "Release_Range") # task release time range Config.tg.random_seed = config.getint("TG_Config", "tg_random_seed") # Config.Task_List = map(int, config.get("TG_Config", "Task_List").split(",")) # Config.Task_WCET_List = map(int, config.get("TG_Config", "Task_WCET_List").split(",")) # Config.Task_Criticality_List = config.get("TG_Config", "Task_Criticality_List").split(",") # TG_Edge_List # TG_Edge_Weight # TG_DOT_Path # ------------------------------------------------ # AG_Config # ------------------------------------------------ Config.ag.type = config.get("AG_Config", "AG_Type") # VirtualChannelNum Config.ag.topology = config.get("AG_Config", "NetworkTopology") Config.ag.x_size = config.getint("AG_Config", "Network_X_Size") Config.ag.y_size = config.getint("AG_Config", "Network_Y_Size") Config.ag.z_size = config.getint("AG_Config", "Network_Z_Size") # Config.PE_List = map(int, config.get("AG_Config", "PE_List").split(",")) # AG_Edge_List # AG_Edge_Port_List # ------------------------------------------------ # VL_Config # ------------------------------------------------ Config.FindOptimumAG = config.getboolean("VL_Config", "FindOptimumAG") Config.vl_opt.vl_opt_alg = config.get("VL_Config", "VL_OptAlg") Config.vl_opt.ils_iteration = config.getint("VL_Config", "AG_Opt_Iterations_ILS") Config.vl_opt.ls_iteration = config.getint("VL_Config", "AG_Opt_Iterations_LS") Config.vl_opt.vl_num = config.getint("VL_Config", "VerticalLinksNum") Config.vl_opt.random_seed = config.getint("VL_Config", "random_seed") Config.vl_opt.sa_annealing_schedule = config.get("VL_Config", "sa_annealing_schedule") Config.vl_opt.termination_criteria = config.get("VL_Config", "termination_criteria") Config.vl_opt.sa_initial_temp = config.getint("VL_Config", "sa_initial_temp") Config.vl_opt.sa_stop_temp = config.getint("VL_Config", "sa_stop_temp") Config.vl_opt.sa_iteration = config.getint("VL_Config", "sa_iteration") Config.vl_opt.sa_report_solutions = config.getboolean( "VL_Config", "sa_report_solutions") Config.vl_opt.sa_alpha = config.getfloat("VL_Config", "sa_alpha") Config.vl_opt.sa_log_cooling_constant = config.getfloat( "VL_Config", "sa_log_cooling_constant") # ------------------------------------------------ # Routing_Config # ------------------------------------------------ if config.get("Routing_Config", "UsedTurnModel") == "XY_TurnModel": Config.UsedTurnModel = PackageFile.XY_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "YX_TurnModel": Config.UsedTurnModel = PackageFile.YX_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "WestFirst_TurnModel": Config.UsedTurnModel = PackageFile.WestFirst_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "NorthLast_TurnModel": Config.UsedTurnModel = PackageFile.NorthLast_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "NegativeFirst2D_TurnModel": Config.UsedTurnModel = PackageFile.NegativeFirst2D_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "XYZ_TurnModel": Config.UsedTurnModel = PackageFile.XYZ_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "NegativeFirst3D_TurnModel": Config.UsedTurnModel = PackageFile.NegativeFirst3D_TurnModel else: raise ValueError("Turn Model not Available") Config.RotingType = config.get("Routing_Config", "RotingType") Config.RoutingFilePath = config.get("Routing_Config", "RoutingFilePath") Config.SetRoutingFromFile = config.getboolean("Routing_Config", "SetRoutingFromFile") Config.FlowControl = config.get("Routing_Config", "FlowControl") Config.TurnsHealth = Config.setup_turns_health() # ------------------------------------------------ # Dark_Sil_Config # ------------------------------------------------ Config.DarkSiliconPercentage = config.getint("Dark_Sil_Config", "DarkSiliconPercentage") # ------------------------------------------------ # SHM_Config # ------------------------------------------------ Config.NumberOfRects = config.getint("SHM_Config", "NumberOfRects") # ListOfBrokenLinks: Config.ListOfBrokenTurns = ast.literal_eval( config.get("SHM_Config", "ListOfBrokenTurns")) Config.MaxTemp = config.getint("SHM_Config", "MaxTemp") # ------------------------------------------------ # CTG_Config # ------------------------------------------------ Config.task_clustering = config.getboolean("CTG_Config", "task_clustering") Config.Clustering_Optimization = config.getboolean( "CTG_Config", "Clustering_Optimization") Config.clustering.iterations = config.getint("CTG_Config", "ClusteringIteration") Config.clustering.random_seed = config.getint("CTG_Config", "ctg_random_seed") Config.clustering.report = config.getboolean("CTG_Config", "Clustering_Report") Config.clustering.detailed_report = config.getboolean( "CTG_Config", "Clustering_DetailedReport") Config.clustering.cost_function = config.get( "CTG_Config", "Clustering_CostFunctionType") Config.clustering.opt_move = config.get("CTG_Config", "ClusteringOptMove") Config.clustering.circulation_length = config.getint( "CTG_Config", "CTG_CirculationLength") # ------------------------------------------------ # Mapping_Config # ------------------------------------------------ Config.read_mapping_from_file = config.getboolean( "Mapping_Config", "read_mapping_from_file") Config.mapping_file_path = config.get("Mapping_Config", "mapping_file_path") Config.Mapping_Function = config.get("Mapping_Config", "Mapping_Function") Config.LocalSearchIteration = config.getint("Mapping_Config", "LocalSearchIteration") Config.IterativeLocalSearchIterations = config.getint( "Mapping_Config", "IterativeLocalSearchIterations") Config.mapping_random_seed = config.getint("Mapping_Config", "mapping_random_seed") Config.SimulatedAnnealingIteration = config.getint( "Mapping_Config", "SimulatedAnnealingIteration") Config.SA_InitialTemp = config.getint("Mapping_Config", "SA_InitialTemp") Config.SA_StopTemp = config.getint("Mapping_Config", "SA_StopTemp") Config.SA_ReportSolutions = config.getboolean("Mapping_Config", "SA_ReportSolutions") Config.SA_AnnealingSchedule = config.get("Mapping_Config", "SA_AnnealingSchedule") Config.TerminationCriteria = config.get("Mapping_Config", "TerminationCriteria") Config.SA_Alpha = config.getfloat("Mapping_Config", "SA_Alpha") Config.LogCoolingConstant = config.getint("Mapping_Config", "LogCoolingConstant") Config.CostMonitorQueSize = config.getint("Mapping_Config", "CostMonitorQueSize") Config.SlopeRangeForCooling = config.getfloat("Mapping_Config", "SlopeRangeForCooling") Config.MaxSteadyState = config.getint("Mapping_Config", "MaxSteadyState") Config.MarkovNum = config.getfloat("Mapping_Config", "MarkovNum") Config.MarkovTempStep = config.getfloat("Mapping_Config", "MarkovTempStep") Config.Delta = config.getfloat("Mapping_Config", "Delta") Config.HuangAlpha = config.getfloat("Mapping_Config", "HuangAlpha") Config.HuangN = config.getint("Mapping_Config", "HuangN") Config.HuangTargetValue1 = config.getint("Mapping_Config", "HuangTargetValue1") Config.HuangTargetValue2 = config.getint("Mapping_Config", "HuangTargetValue2") Config.Mapping_CostFunctionType = config.get("Mapping_Config", "Mapping_CostFunctionType") Config.DistanceBetweenMapping = config.getboolean( "Mapping_Config", "DistanceBetweenMapping") # ------------------------------------------------ # Scheduling_Config # ------------------------------------------------ Config.Communication_SlackCount = config.getint( "Scheduling_Config", "Communication_SlackCount") Config.Task_SlackCount = config.getint("Scheduling_Config", "Task_SlackCount") # ------------------------------------------------ # Fault_Config # ------------------------------------------------ Config.MTBF = config.getfloat("Fault_Config", "MTBF") # Config.SD4MTBF = 0.2 Config.classification_method = config.get("Fault_Config", "classification_method") Config.health_counter_threshold = config.getint( "Fault_Config", "health_counter_threshold") Config.fault_counter_threshold = config.getint("Fault_Config", "fault_counter_threshold") Config.intermittent_counter_threshold = config.getint( "Fault_Config", "intermittent_counter_threshold") Config.enable_link_counters = config.getboolean("Fault_Config", "enable_link_counters") Config.enable_router_counters = config.getboolean( "Fault_Config", "enable_router_counters") Config.enable_pe_counters = config.getboolean("Fault_Config", "enable_pe_counters") Config.error_correction_rate = config.getfloat("Fault_Config", "error_correction_rate") # ------------------------------------------------ # Network_Partitioning # ------------------------------------------------ Config.EnablePartitioning = config.getboolean("Network_Partitioning", "EnablePartitioning") # ------------------------------------------------ # PMCG_Config # ------------------------------------------------ Config.GeneratePMCG = config.getboolean("PMCG_Config", "GeneratePMCG") Config.OneStepDiagnosable = config.getboolean("PMCG_Config", "OneStepDiagnosable") Config.TFaultDiagnosable = config.get("PMCG_Config", "TFaultDiagnosable") Config.NodeTestExeTime = config.getint("PMCG_Config", "NodeTestExeTime") Config.NodeTestComWeight = config.getint("PMCG_Config", "NodeTestComWeight") # ------------------------------------------------ # Viz_Config # ------------------------------------------------ Config.viz.rg = config.getboolean("Viz_Config", "RG_Draw") Config.viz.pmcg = config.getboolean("Viz_Config", "PMCG_Drawing") Config.viz.ttg = config.getboolean("Viz_Config", "TTG_Drawing") Config.viz.mapping_distribution = config.getboolean( "Viz_Config", "Mapping_Dstr_Drawing") Config.viz.mapping = config.getboolean("Viz_Config", "Mapping_Drawing") Config.viz.scheduling = config.getboolean("Viz_Config", "Scheduling_Drawing") Config.viz.shm = config.getboolean("Viz_Config", "SHM_Drawing") Config.viz.mapping_frames = config.getboolean("Viz_Config", "GenMappingFrames") Config.viz.frame_resolution = config.getint("Viz_Config", "FrameResolution") return None
def report_3d_turn_model_fault_tolerance(turn_model, viz, combination): """ generates 3D architecture graph with all combinations C(len(ag.nodes), combination) of links and writes the average connectivity metric in a file. :param turn_model: list of allowed turns for generating the routing graph :param combination: number of links to be present in the network :param viz: if true, generates the visualization files :return: None """ if combination == 108: raise ValueError( "breaking 108 edges out of 108 edges is not possible your connectivity is 0!" ) Config.UsedTurnModel = copy.deepcopy(turn_model) Config.TurnsHealth = copy.deepcopy(Config.setup_turns_health()) ag = copy.deepcopy(AG_Functions.generate_ag(report=False)) turn_model_name = return_turn_model_name(Config.UsedTurnModel) file_name = str(turn_model_name) + '_eval' turn_model_eval_file = open( 'Generated_Files/Turn_Model_Eval/' + file_name + '.txt', 'a+') if viz: file_name_viz = str(turn_model_name) + '_eval_' + str( len(ag.edges()) - combination) turn_model_eval_viz_file = open( 'Generated_Files/Internal/' + file_name_viz + '.txt', 'w') else: turn_model_eval_viz_file = None counter = 0 metric_sum = 0 list_of_avg = [] number_of_combinations = comb(108, combination) while True: sub_ag = sample(ag.edges(), combination) shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, copy.deepcopy(Config.TurnsHealth), False) for link in list(sub_ag): shmu.break_link(link, False) noc_rg = copy.deepcopy( Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, False, False)) connectivity_metric = reachability_metric(ag, noc_rg, False) counter += 1 metric_sum += connectivity_metric # std = None list_of_avg.append(float(metric_sum) / counter) if len(list_of_avg) > 5000: list_of_avg.pop(0) std = stdev(list_of_avg) if std < 0.009: # turn_model_eval_file.write("STD of the last 5000 average samples is bellow 0.009\n") # turn_model_eval_file.write("Terminating the search!\n") del shmu del noc_rg break if viz: turn_model_eval_viz_file.write( str(float(metric_sum) / counter) + "\n") if counter >= number_of_combinations: del shmu del noc_rg break # print("#:"+str(counter)+"\t\tC.M.:"+str(connectivity_metric)+"\t\t avg:", \ # float(metric_sum)/counter, "\t\tstd:", std) del shmu del noc_rg if counter > 0: avg_connectivity = float(metric_sum) / counter else: avg_connectivity = 0 turn_model_eval_file.write( str(len(ag.edges()) - combination) + "\t\t" + str(avg_connectivity) + "\n") turn_model_eval_file.close() if viz: turn_model_eval_viz_file.close() return None
def update_config(config_file_path): try: config_file = open(config_file_path, 'r') config_file.close() except IOError: print ('CAN NOT OPEN config_file') config = ConfigParser.ConfigParser(allow_no_value=True) config.read(config_file_path) # ------------------------------------------------ # Program_Config # ------------------------------------------------ Config.enable_simulator = config.getboolean("Program_Config", "enable_simulator") Config.ProgramRunTime = config.getint("Program_Config", "ProgramRunTime") Config.DebugInfo = config.getboolean("Program_Config", "DebugInfo") Config.DebugDetails = config.getboolean("Program_Config", "DebugDetails") Config.TestMode = config.getboolean("Program_Config", "TestMode") Config.MemoryProfiler = config.getboolean("Program_Config", "MemoryProfiler") Config.EventDrivenFaultInjection = config.getboolean("Program_Config", "EventDrivenFaultInjection") Config.fault_injection_method = config.get("Program_Config", "fault_injection_method") Config.fault_injection_file = config.get("Program_Config", "fault_injection_file") # ------------------------------------------------ # TG_Config # ------------------------------------------------ Config.tg.type = config.get("TG_Config", "TG_Type") Config.tg.num_of_tasks = config.getint("TG_Config", "NumberOfTasks") Config.tg.num_of_critical_tasks = config.getint("TG_Config", "NumberOfCriticalTasks") Config.tg.num_of_edges = config.getint("TG_Config", "NumberOfEdges") Config.tg.wcet_range = config.getint("TG_Config", "WCET_Range") Config.tg.edge_weight_range = config.getint("TG_Config", "EdgeWeightRange") Config.tg.release_range = config.getint("TG_Config", "Release_Range") # task release time range Config.tg.random_seed = config.getint("TG_Config", "tg_random_seed") # Config.Task_List = map(int, config.get("TG_Config", "Task_List").split(",")) # Config.Task_WCET_List = map(int, config.get("TG_Config", "Task_WCET_List").split(",")) # Config.Task_Criticality_List = config.get("TG_Config", "Task_Criticality_List").split(",") # TG_Edge_List # TG_Edge_Weight # TG_DOT_Path # ------------------------------------------------ # AG_Config # ------------------------------------------------ Config.ag.type = config.get("AG_Config", "AG_Type") # VirtualChannelNum Config.ag.topology = config.get("AG_Config", "NetworkTopology") Config.ag.x_size = config.getint("AG_Config", "Network_X_Size") Config.ag.y_size = config.getint("AG_Config", "Network_Y_Size") Config.ag.z_size = config.getint("AG_Config", "Network_Z_Size") # Config.PE_List = map(int, config.get("AG_Config", "PE_List").split(",")) # AG_Edge_List # AG_Edge_Port_List # ------------------------------------------------ # VL_Config # ------------------------------------------------ Config.FindOptimumAG = config.getboolean("VL_Config", "FindOptimumAG") Config.vl_opt.vl_opt_alg = config.get("VL_Config", "VL_OptAlg") Config.vl_opt.ils_iteration = config.getint("VL_Config", "AG_Opt_Iterations_ILS") Config.vl_opt.ls_iteration = config.getint("VL_Config", "AG_Opt_Iterations_LS") Config.vl_opt.vl_num = config.getint("VL_Config", "VerticalLinksNum") Config.vl_opt.random_seed = config.getint("VL_Config", "random_seed") Config.vl_opt.sa_annealing_schedule = config.get("VL_Config", "sa_annealing_schedule") Config.vl_opt.termination_criteria = config.get("VL_Config", "termination_criteria") Config.vl_opt.sa_initial_temp = config.getint("VL_Config", "sa_initial_temp") Config.vl_opt.sa_stop_temp = config.getint("VL_Config", "sa_stop_temp") Config.vl_opt.sa_iteration = config.getint("VL_Config", "sa_iteration") Config.vl_opt.sa_report_solutions = config.getboolean("VL_Config", "sa_report_solutions") Config.vl_opt.sa_alpha = config.getfloat("VL_Config", "sa_alpha") Config.vl_opt.sa_log_cooling_constant = config.getfloat("VL_Config", "sa_log_cooling_constant") # ------------------------------------------------ # Routing_Config # ------------------------------------------------ if config.get("Routing_Config", "UsedTurnModel") == "XY_TurnModel": Config.UsedTurnModel = PackageFile.XY_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "YX_TurnModel": Config.UsedTurnModel = PackageFile.YX_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "WestFirst_TurnModel": Config.UsedTurnModel = PackageFile.WestFirst_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "NorthLast_TurnModel": Config.UsedTurnModel = PackageFile.NorthLast_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "NegativeFirst2D_TurnModel": Config.UsedTurnModel = PackageFile.NegativeFirst2D_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "XYZ_TurnModel": Config.UsedTurnModel = PackageFile.XYZ_TurnModel elif config.get("Routing_Config", "UsedTurnModel") == "NegativeFirst3D_TurnModel": Config.UsedTurnModel = PackageFile.NegativeFirst3D_TurnModel else: raise ValueError("Turn Model not Available") Config.RotingType = config.get("Routing_Config", "RotingType") Config.RoutingFilePath = config.get("Routing_Config", "RoutingFilePath") Config.SetRoutingFromFile = config.getboolean("Routing_Config", "SetRoutingFromFile") Config.FlowControl = config.get("Routing_Config", "FlowControl") Config.TurnsHealth = Config.setup_turns_health() # ------------------------------------------------ # Dark_Sil_Config # ------------------------------------------------ Config.DarkSiliconPercentage = config.getint("Dark_Sil_Config", "DarkSiliconPercentage") # ------------------------------------------------ # SHM_Config # ------------------------------------------------ Config.NumberOfRects = config.getint("SHM_Config", "NumberOfRects") # ListOfBrokenLinks: Config.ListOfBrokenTurns = ast.literal_eval(config.get("SHM_Config", "ListOfBrokenTurns")) Config.MaxTemp = config.getint("SHM_Config", "MaxTemp") # ------------------------------------------------ # CTG_Config # ------------------------------------------------ Config.task_clustering = config.getboolean("CTG_Config", "task_clustering") Config.Clustering_Optimization = config.getboolean("CTG_Config", "Clustering_Optimization") Config.clustering.iterations = config.getint("CTG_Config", "ClusteringIteration") Config.clustering.random_seed = config.getint("CTG_Config", "ctg_random_seed") Config.clustering.report = config.getboolean("CTG_Config", "Clustering_Report") Config.clustering.detailed_report = config.getboolean("CTG_Config", "Clustering_DetailedReport") Config.clustering.cost_function = config.get("CTG_Config", "Clustering_CostFunctionType") Config.clustering.opt_move = config.get("CTG_Config", "ClusteringOptMove") Config.clustering.circulation_length = config.getint("CTG_Config", "CTG_CirculationLength") # ------------------------------------------------ # Mapping_Config # ------------------------------------------------ Config.read_mapping_from_file = config.getboolean("Mapping_Config", "read_mapping_from_file") Config.mapping_file_path = config.get("Mapping_Config", "mapping_file_path") Config.Mapping_Function = config.get("Mapping_Config", "Mapping_Function") Config.LocalSearchIteration = config.getint("Mapping_Config", "LocalSearchIteration") Config.IterativeLocalSearchIterations = config.getint("Mapping_Config", "IterativeLocalSearchIterations") Config.mapping_random_seed = config.getint("Mapping_Config", "mapping_random_seed") Config.SimulatedAnnealingIteration = config.getint("Mapping_Config", "SimulatedAnnealingIteration") Config.SA_InitialTemp = config.getint("Mapping_Config", "SA_InitialTemp") Config.SA_StopTemp = config.getint("Mapping_Config", "SA_StopTemp") Config.SA_ReportSolutions = config.getboolean("Mapping_Config", "SA_ReportSolutions") Config.SA_AnnealingSchedule = config.get("Mapping_Config", "SA_AnnealingSchedule") Config.TerminationCriteria = config.get("Mapping_Config", "TerminationCriteria") Config.SA_Alpha = config.getfloat("Mapping_Config", "SA_Alpha") Config.LogCoolingConstant = config.getint("Mapping_Config", "LogCoolingConstant") Config.CostMonitorQueSize = config.getint("Mapping_Config", "CostMonitorQueSize") Config.SlopeRangeForCooling = config.getfloat("Mapping_Config", "SlopeRangeForCooling") Config.MaxSteadyState = config.getint("Mapping_Config", "MaxSteadyState") Config.MarkovNum = config.getfloat("Mapping_Config", "MarkovNum") Config.MarkovTempStep = config.getfloat("Mapping_Config", "MarkovTempStep") Config.Delta = config.getfloat("Mapping_Config", "Delta") Config.HuangAlpha = config.getfloat("Mapping_Config", "HuangAlpha") Config.HuangN = config.getint("Mapping_Config", "HuangN") Config.HuangTargetValue1 = config.getint("Mapping_Config", "HuangTargetValue1") Config.HuangTargetValue2 = config.getint("Mapping_Config", "HuangTargetValue2") Config.Mapping_CostFunctionType = config.get("Mapping_Config", "Mapping_CostFunctionType") Config.DistanceBetweenMapping = config.getboolean("Mapping_Config", "DistanceBetweenMapping") # ------------------------------------------------ # Scheduling_Config # ------------------------------------------------ Config.Communication_SlackCount = config.getint("Scheduling_Config", "Communication_SlackCount") Config.Task_SlackCount = config.getint("Scheduling_Config", "Task_SlackCount") # ------------------------------------------------ # Fault_Config # ------------------------------------------------ Config.MTBF = config.getfloat("Fault_Config", "MTBF") # Config.SD4MTBF = 0.2 Config.classification_method = config.get("Fault_Config", "classification_method") Config.health_counter_threshold = config.getint("Fault_Config", "health_counter_threshold") Config.fault_counter_threshold = config.getint("Fault_Config", "fault_counter_threshold") Config.intermittent_counter_threshold = config.getint("Fault_Config", "intermittent_counter_threshold") Config.enable_link_counters = config.getboolean("Fault_Config", "enable_link_counters") Config.enable_router_counters = config.getboolean("Fault_Config", "enable_router_counters") Config.enable_pe_counters = config.getboolean("Fault_Config", "enable_pe_counters") Config.error_correction_rate = config.getfloat("Fault_Config", "error_correction_rate") # ------------------------------------------------ # Network_Partitioning # ------------------------------------------------ Config.EnablePartitioning = config.getboolean("Network_Partitioning", "EnablePartitioning") # ------------------------------------------------ # PMCG_Config # ------------------------------------------------ Config.GeneratePMCG = config.getboolean("PMCG_Config", "GeneratePMCG") Config.OneStepDiagnosable = config.getboolean("PMCG_Config", "OneStepDiagnosable") Config.TFaultDiagnosable = config.get("PMCG_Config", "TFaultDiagnosable") Config.NodeTestExeTime = config.getint("PMCG_Config", "NodeTestExeTime") Config.NodeTestComWeight = config.getint("PMCG_Config", "NodeTestComWeight") # ------------------------------------------------ # Viz_Config # ------------------------------------------------ Config.viz.rg = config.getboolean("Viz_Config", "RG_Draw") Config.viz.pmcg = config.getboolean("Viz_Config", "PMCG_Drawing") Config.viz.ttg = config.getboolean("Viz_Config", "TTG_Drawing") Config.viz.mapping_distribution = config.getboolean("Viz_Config", "Mapping_Dstr_Drawing") Config.viz.mapping = config.getboolean("Viz_Config", "Mapping_Drawing") Config.viz.scheduling = config.getboolean("Viz_Config", "Scheduling_Drawing") Config.viz.shm = config.getboolean("Viz_Config", "SHM_Drawing") Config.viz.mapping_frames = config.getboolean("Viz_Config", "GenMappingFrames") Config.viz.frame_resolution = config.getint("Viz_Config", "FrameResolution") return None
def initialize_system(logging): """ Generates the Task graph, Architecture Graph, System Health Monitoring Unit, NoC routing graph(s) and Test Task Graphs and does the mapping and scheduling and returns to the user the initial system :param logging: logging file :return: tg, ag, shmu, noc_rg, critical_rg, noncritical_rg, pmcg """ tg = copy.deepcopy(TG_Functions.generate_tg()) if Config.DebugInfo: Task_Graph_Reports.report_task_graph(tg, logging) Task_Graph_Reports.draw_task_graph(tg) if Config.TestMode: TG_Test.check_acyclic(tg, logging) #################################################################### ag = copy.deepcopy(AG_Functions.generate_ag(logging)) AG_Functions.update_ag_regions(ag) AG_Functions.random_darkness(ag) if Config.EnablePartitioning: AG_Functions.setup_network_partitioning(ag) if Config.FindOptimumAG: Arch_Graph_Reports.draw_ag(ag, "AG_Full") else: Arch_Graph_Reports.draw_ag(ag, "AG") #################################################################### Config.setup_turns_health() shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, Config.TurnsHealth, True) # Here we are injecting initial faults of the system: we assume these fault # information is obtained by post manufacturing system diagnosis if Config.FindOptimumAG: vl_opt.optimize_ag_vertical_links(ag, shmu, logging) vl_opt_functions.cleanup_ag(ag, shmu) Arch_Graph_Reports.draw_ag(ag, "AG_VLOpt") SHMU_Functions.apply_initial_faults(shmu) if Config.viz.shm: SHMU_Reports.draw_shm(shmu.SHM) SHMU_Reports.draw_temp_distribution(shmu.SHM) # SHM_Reports.report_noc_shm() #################################################################### routing_graph_start_time = time.time() if Config.SetRoutingFromFile: noc_rg = copy.deepcopy(Routing.gen_noc_route_graph_from_file(ag, shmu, Config.RoutingFilePath, Config.DebugInfo, Config.DebugDetails)) else: noc_rg = copy.deepcopy(Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, Config.DebugInfo, Config.DebugDetails)) Routing_Functions.check_deadlock_freeness(noc_rg) print ("\033[92mTIME::\033[0m ROUTING GRAPH GENERATION TOOK: " + str(round(time.time()-routing_graph_start_time))+" SECONDS") # this is for double checking... if Config.FindOptimumAG: Calculate_Reachability.reachability_metric(ag, noc_rg, True) # Some visualization... if Config.viz.rg: RoutingGraph_Reports.draw_rg(noc_rg) #################################################################### # in case of partitioning, we have to route based on different Route-graphs if Config.EnablePartitioning: critical_rg, noncritical_rg = Calculate_Reachability.calculate_reachability_with_regions(ag, shmu) ReachabilityReports.report_gsnoc_friendly_reachability_in_file(ag) else: critical_rg, noncritical_rg = None, None Calculate_Reachability.calculate_reachability(ag, noc_rg) Calculate_Reachability.optimize_reachability_rectangles(ag, Config.NumberOfRects) # ReachabilityReports.report_reachability(ag) ReachabilityReports.report_reachability_in_file(ag, "ReachAbilityNodeReport") ReachabilityReports.report_gsnoc_friendly_reachability_in_file(ag) #################################################################### if Config.read_mapping_from_file: Mapping_Functions.read_mapping_from_file(tg, ag, shmu.SHM, noc_rg, critical_rg, noncritical_rg, Config.mapping_file_path, logging) Scheduler.schedule_all(tg, ag, shmu.SHM, False, logging) else: best_tg, best_ag = Mapping.mapping(tg, ag, noc_rg, critical_rg, noncritical_rg, shmu.SHM, logging) if best_ag is not None and best_tg is not None: tg = copy.deepcopy(best_tg) ag = copy.deepcopy(best_ag) del best_tg, best_ag # SHM.add_current_mapping_to_mpm(tg) Mapping_Functions.write_mapping_to_file(ag, "mapping_report") if Config.viz.mapping_distribution: Mapping_Reports.draw_mapping_distribution(ag, shmu) if Config.viz.mapping: Mapping_Reports.draw_mapping(tg, ag, shmu.SHM, "Mapping_post_opt") if Config.viz.scheduling: Scheduling_Reports.generate_gantt_charts(tg, ag, "SchedulingTG") #################################################################### # PMC-Graph # at this point we assume that the system health map knows about the initial faults from # the diagnosis process if Config.GeneratePMCG: pmcg_start_time = time.time() if Config.OneStepDiagnosable: pmcg = TestSchedulingUnit.gen_one_step_diagnosable_pmcg(ag, shmu.SHM) else: pmcg = TestSchedulingUnit.gen_sequentially_diagnosable_pmcg(ag, shmu.SHM) test_tg = TestSchedulingUnit.generate_test_tg_from_pmcg(pmcg) print ("\033[92mTIME::\033[0m PMCG AND TTG GENERATION TOOK: " + str(round(time.time()-pmcg_start_time)) + " SECONDS") if Config.viz.pmcg: TestSchedulingUnit.draw_pmcg(pmcg) if Config.viz.ttg: TestSchedulingUnit.draw_ttg(test_tg) TestSchedulingUnit.insert_test_tasks_in_tg(pmcg, tg) Task_Graph_Reports.draw_task_graph(tg, ttg=test_tg) TestSchedulingUnit.map_test_tasks(tg, ag, shmu.SHM, noc_rg, logging) Scheduler.schedule_test_in_tg(tg, ag, shmu.SHM, False, logging) Scheduling_Reports.report_mapped_tasks(ag, logging) # TestSchedulingUnit.remove_test_tasks_from_tg(test_tg, tg) # Task_Graph_Reports.draw_task_graph(tg, TTG=test_tg) Scheduling_Reports.generate_gantt_charts(tg, ag, "SchedulingWithTTG") else: pmcg = None Arch_Graph_Reports.gen_latex_ag(ag, shmu.SHM) print ("===========================================") print ("SYSTEM IS UP...") TrafficTableGenerator.generate_noxim_traffic_table(ag, tg) if Config.viz.mapping_frames: Mapping_Animation.generate_frames(ag, shmu.SHM) return tg, ag, shmu, noc_rg, critical_rg, noncritical_rg, pmcg
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) 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
def initialize_system(logging): """ Generates the Task graph, Architecture Graph, System Health Monitoring Unit, NoC routing graph(s) and Test Task Graphs and does the mapping and scheduling and returns to the user the initial system :param logging: logging file :return: tg, ag, shmu, noc_rg, critical_rg, noncritical_rg, pmcg """ tg = copy.deepcopy(TG_Functions.generate_tg()) if Config.DebugInfo: Task_Graph_Reports.report_task_graph(tg, logging) Task_Graph_Reports.draw_task_graph(tg) if Config.TestMode: TG_Test.CheckAcyclic(tg, logging) #################################################################### ag = copy.deepcopy(AG_Functions.generate_ag(logging)) AG_Functions.update_ag_regions(ag) AG_Functions.random_darkness(ag) if Config.EnablePartitioning: AG_Functions.setup_network_partitioning(ag) if Config.TestMode: AG_Test.ag_test() if Config.FindOptimumAG: Arch_Graph_Reports.draw_ag(ag, "AG_Full") else: Arch_Graph_Reports.draw_ag(ag, "AG") #################################################################### Config.setup_turns_health() if Config.TestMode: SHMU_Test.test_shmu(ag) shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, Config.TurnsHealth) # Here we are injecting initial faults of the system: we assume these fault # information is obtained by post manufacturing system diagnosis if Config.FindOptimumAG: Optimize_3D_AG.optimize_ag_vertical_links(ag, shmu, logging) Optimize_3D_AG.cleanup_ag(ag, shmu) Arch_Graph_Reports.draw_ag(ag, "AG_VLOpt") SHMU_Functions.ApplyInitialFaults(shmu) if Config.SHM_Drawing: SHMU_Reports.DrawSHM(shmu.SHM) SHMU_Reports.DrawTempDistribution(shmu.SHM) # SHM_Reports.Report_NoC_SystemHealthMap() #################################################################### routing_graph_start_time = time.time() if Config.SetRoutingFromFile: noc_rg = copy.deepcopy( Routing.GenerateNoCRouteGraphFromFile(ag, shmu, Config.RoutingFilePath, Config.DebugInfo, Config.DebugDetails)) else: noc_rg = copy.deepcopy( Routing.GenerateNoCRouteGraph(ag, shmu, Config.UsedTurnModel, Config.DebugInfo, Config.DebugDetails)) print("\033[92mTIME::\033[0m ROUTING GRAPH GENERATION TOOK: " + str(round(time.time() - routing_graph_start_time)) + " SECONDS") # this is for double checking... if Config.FindOptimumAG: Calculate_Reachability.ReachabilityMetric(ag, noc_rg, True) # Some visualization... if Config.RG_Draw: RoutingGraph_Reports.draw_rg(noc_rg) #################################################################### # in case of partitioning, we have to route based on different Route-graphs if Config.EnablePartitioning: critical_rg, noncritical_rg = Calculate_Reachability.calculate_reachability_with_regions( ag, shmu) ReachabilityReports.ReportGSNoCFriendlyReachabilityInFile(ag) else: if Config.TestMode: Reachability_Test.ReachabilityTest() critical_rg, noncritical_rg = None, None Calculate_Reachability.calculate_reachability(ag, noc_rg) Calculate_Reachability.OptimizeReachabilityRectangles( ag, Config.NumberOfRects) # ReachabilityReports.ReportReachability(ag) ReachabilityReports.ReportReachabilityInFile(ag, "ReachAbilityNodeReport") ReachabilityReports.ReportGSNoCFriendlyReachabilityInFile(ag) #################################################################### if Config.read_mapping_from_file: Mapping_Functions.read_mapping_from_file(tg, ag, shmu.SHM, noc_rg, critical_rg, noncritical_rg, Config.mapping_file_path, logging) Scheduler.schedule_all(tg, ag, shmu.SHM, False, False, logging) else: best_tg, best_ag = Mapping.mapping(tg, ag, noc_rg, critical_rg, noncritical_rg, shmu.SHM, logging) if best_ag is not None and best_tg is not None: tg = copy.deepcopy(best_tg) ag = copy.deepcopy(best_ag) del best_tg, best_ag # SHM.AddCurrentMappingToMPM(tg) Mapping_Functions.write_mapping_to_file(ag, "mapping_report") if Config.Mapping_Dstr_Drawing: Mapping_Reports.draw_mapping_distribution(ag, shmu) if Config.Mapping_Drawing: Mapping_Reports.draw_mapping(tg, ag, shmu.SHM, "Mapping_post_opt") if Config.Scheduling_Drawing: Scheduling_Reports.generate_gantt_charts(tg, ag, "SchedulingTG") #################################################################### # PMC-Graph # at this point we assume that the system health map knows about the initial faults from # the diagnosis process if Config.GeneratePMCG: pmcg_start_time = time.time() if Config.OneStepDiagnosable: pmcg = TestSchedulingUnit.GenerateOneStepDiagnosablePMCG( ag, shmu.SHM) else: pmcg = TestSchedulingUnit.GenerateSequentiallyDiagnosablePMCG( ag, shmu.SHM) test_tg = TestSchedulingUnit.GenerateTestTGFromPMCG(pmcg) print("\033[92mTIME::\033[0m PMCG AND TTG GENERATION TOOK: " + str(round(time.time() - pmcg_start_time)) + " SECONDS") if Config.PMCG_Drawing: TestSchedulingUnit.DrawPMCG(pmcg) if Config.TTG_Drawing: TestSchedulingUnit.DrawTTG(test_tg) TestSchedulingUnit.InsertTestTasksInTG(pmcg, tg) Task_Graph_Reports.draw_task_graph(tg, ttg=test_tg) TestSchedulingUnit.MapTestTasks(tg, ag, shmu.SHM, noc_rg, logging) Scheduler.schedule_test_in_tg(tg, ag, shmu.SHM, False, logging) Scheduling_Reports.report_mapped_tasks(ag, logging) # TestSchedulingUnit.RemoveTestTasksFromTG(test_tg, tg) # Task_Graph_Reports.draw_task_graph(tg, TTG=test_tg) Scheduling_Reports.generate_gantt_charts(tg, ag, "SchedulingWithTTG") else: pmcg = None print("===========================================") print("SYSTEM IS UP...") TrafficTableGenerator.generate_noxim_traffic_table(ag, tg) TrafficTableGenerator.generate_gsnoc_traffic_table(ag, tg) if Config.GenMappingFrames: Mapping_Animation.generate_frames(tg, ag, shmu.SHM) return ag, shmu, noc_rg, critical_rg, noncritical_rg, pmcg
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
def initialize_system(logging): """ Generates the Task graph, Architecture Graph, System Health Monitoring Unit, NoC routing graph(s) and Test Task Graphs and does the mapping and scheduling and returns to the user the initial system :param logging: logging file :return: tg, ag, shmu, noc_rg, critical_rg, noncritical_rg, pmcg """ tg = copy.deepcopy(TG_Functions.generate_tg()) if Config.DebugInfo: Task_Graph_Reports.report_task_graph(tg, logging) Task_Graph_Reports.draw_task_graph(tg) if Config.TestMode: TG_Test.check_acyclic(tg, logging) #################################################################### ag = copy.deepcopy(AG_Functions.generate_ag(logging)) AG_Functions.update_ag_regions(ag) AG_Functions.random_darkness(ag) if Config.EnablePartitioning: AG_Functions.setup_network_partitioning(ag) if Config.FindOptimumAG: Arch_Graph_Reports.draw_ag(ag, "AG_Full") else: Arch_Graph_Reports.draw_ag(ag, "AG") #################################################################### Config.setup_turns_health() shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, Config.TurnsHealth, True) # Here we are injecting initial faults of the system: we assume these fault # information is obtained by post manufacturing system diagnosis if Config.FindOptimumAG: vl_opt.optimize_ag_vertical_links(ag, shmu, logging) vl_opt_functions.cleanup_ag(ag, shmu) Arch_Graph_Reports.draw_ag(ag, "AG_VLOpt") SHMU_Functions.apply_initial_faults(shmu) if Config.viz.shm: SHMU_Reports.draw_shm(shmu.SHM) SHMU_Reports.draw_temp_distribution(shmu.SHM) # SHM_Reports.report_noc_shm() #################################################################### routing_graph_start_time = time.time() if Config.SetRoutingFromFile: noc_rg = copy.deepcopy(Routing.gen_noc_route_graph_from_file(ag, shmu, Config.RoutingFilePath, Config.DebugInfo, Config.DebugDetails)) else: noc_rg = copy.deepcopy(Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, Config.DebugInfo, Config.DebugDetails)) Routing_Functions.check_deadlock_freeness(noc_rg) print("\033[92mTIME::\033[0m ROUTING GRAPH GENERATION TOOK: " + str(round(time.time()-routing_graph_start_time))+" SECONDS") # this is for double checking... if Config.FindOptimumAG: Calculate_Reachability.reachability_metric(ag, noc_rg, True) # Some visualization... if Config.viz.rg: RoutingGraph_Reports.draw_rg(noc_rg) #################################################################### # in case of partitioning, we have to route based on different Route-graphs if Config.EnablePartitioning: critical_rg, noncritical_rg = Calculate_Reachability.calculate_reachability_with_regions(ag, shmu) ReachabilityReports.report_gsnoc_friendly_reachability_in_file(ag) else: critical_rg, noncritical_rg = None, None Calculate_Reachability.calculate_reachability(ag, noc_rg) Calculate_Reachability.optimize_reachability_rectangles(ag, Config.NumberOfRects) # ReachabilityReports.report_reachability(ag) ReachabilityReports.report_reachability_in_file(ag, "ReachAbilityNodeReport") ReachabilityReports.report_gsnoc_friendly_reachability_in_file(ag) #################################################################### if Config.read_mapping_from_file: Mapping_Functions.read_mapping_from_file(tg, ag, shmu.SHM, noc_rg, critical_rg, noncritical_rg, Config.mapping_file_path, logging) Scheduler.schedule_all(tg, ag, shmu.SHM, False, logging) else: best_tg, best_ag = Mapping.mapping(tg, ag, noc_rg, critical_rg, noncritical_rg, shmu.SHM, logging) if best_ag is not None and best_tg is not None: tg = copy.deepcopy(best_tg) ag = copy.deepcopy(best_ag) del best_tg, best_ag # SHM.add_current_mapping_to_mpm(tg) Mapping_Functions.write_mapping_to_file(ag, "mapping_report") if Config.viz.mapping_distribution: Mapping_Reports.draw_mapping_distribution(ag, shmu) if Config.viz.mapping: Mapping_Reports.draw_mapping(tg, ag, shmu.SHM, "Mapping_post_opt") if Config.viz.scheduling: Scheduling_Reports.generate_gantt_charts(tg, ag, "SchedulingTG") #################################################################### # PMC-Graph # at this point we assume that the system health map knows about the initial faults from # the diagnosis process if Config.GeneratePMCG: pmcg_start_time = time.time() if Config.OneStepDiagnosable: pmcg = TestSchedulingUnit.gen_one_step_diagnosable_pmcg(ag, shmu.SHM) else: pmcg = TestSchedulingUnit.gen_sequentially_diagnosable_pmcg(ag, shmu.SHM) test_tg = TestSchedulingUnit.generate_test_tg_from_pmcg(pmcg) print("\033[92mTIME::\033[0m PMCG AND TTG GENERATION TOOK: " + str(round(time.time()-pmcg_start_time)) + " SECONDS") if Config.viz.pmcg: TestSchedulingUnit.draw_pmcg(pmcg) if Config.viz.ttg: TestSchedulingUnit.draw_ttg(test_tg) TestSchedulingUnit.insert_test_tasks_in_tg(pmcg, tg) Task_Graph_Reports.draw_task_graph(tg, ttg=test_tg) TestSchedulingUnit.map_test_tasks(tg, ag, shmu.SHM, noc_rg, logging) Scheduler.schedule_test_in_tg(tg, ag, shmu.SHM, False, logging) Scheduling_Reports.report_mapped_tasks(ag, logging) # TestSchedulingUnit.remove_test_tasks_from_tg(test_tg, tg) # Task_Graph_Reports.draw_task_graph(tg, TTG=test_tg) Scheduling_Reports.generate_gantt_charts(tg, ag, "SchedulingWithTTG") else: pmcg = None Arch_Graph_Reports.gen_latex_ag(ag, shmu.SHM) print("===========================================") print("SYSTEM IS UP...") TrafficTableGenerator.generate_noxim_traffic_table(ag, tg) if Config.viz.mapping_frames: Mapping_Animation.generate_frames(ag, shmu.SHM) return tg, ag, shmu, noc_rg, critical_rg, noncritical_rg, pmcg
def test_routing_functions(self): # backing up the original config... 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.RotingType = "MinimalPath" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 1 for turn_model in PackageFile.routing_alg_list_2d: tmName = return_turn_model_name(turn_model) 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=f"TM {tmName} Deadlock freeness failed") if turn_model in [ PackageFile.XY_TurnModel, PackageFile.YX_TurnModel ]: if turn_model == PackageFile.XY_TurnModel: self.assertEqual(tmName, '0', msg=f"TM name {tmName} is not 0") else: self.assertEqual(tmName, '13', msg=f"TM name {tmName} is not 13") self.assertEqual( degree_of_adaptiveness(ag_4_test, noc_rg, report=False) / 72.0, 1.0, msg=f"TM: {tmName} DOA failed") self.assertEqual(extended_degree_of_adaptiveness( ag_4_test, noc_rg, report=False) / 72.0, 1.0, msg=f"TM: {tmName} DOAex failed") del ag_4_test del shmu_4_test # ----------------------------------------------------- Config.ag.type = "Generic" Config.ag.topology = "3DMesh" Config.RotingType = "NonMinimalPath" Config.ag.x_size = 3 Config.ag.y_size = 3 Config.ag.z_size = 3 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=f"TM: {turn_model} deadlock freeness Failed!") if turn_model == PackageFile.XYZ_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_XYZ", msg="Turn Model is not 3d_XYZ") self.assertEqual( degree_of_adaptiveness(ag_4_test, noc_rg, False) / 702, 1, msg="DoA test failed") self.assertEqual( extended_degree_of_adaptiveness(ag_4_test, noc_rg, False) / 702, 1, msg="ExDoA test failed") if turn_model == PackageFile.NegativeFirst3D_TurnModel: self.assertEqual(return_turn_model_name(turn_model), "3d_NegFirst", msg="TM name is not 3d_NegFirst") del ag_4_test del shmu_4_test del noc_rg # ----------------------------------------------------- # going back to original config Config.ag = deepcopy(initial_config_ag) Config.UsedTurnModel = initial_turn_model Config.TurnsHealth = deepcopy(Config.setup_turns_health()) Config.RotingType = initial_routing_type
def report_3d_turn_model_fault_tolerance(turn_model, viz, combination): """ generates 3D architecture graph with all combinations C(len(ag.nodes), combination) of links and writes the average connectivity metric in a file. :param turn_model: list of allowed turns for generating the routing graph :param combination: number of links to be present in the network :param viz: if true, generates the visualization files :return: None """ if combination == 108: raise ValueError("breaking 108 edges out of 108 edges is not possible your connectivity is 0!") Config.UsedTurnModel = copy.deepcopy(turn_model) Config.TurnsHealth = copy.deepcopy(Config.setup_turns_health()) ag = copy.deepcopy(AG_Functions.generate_ag(report=False)) turn_model_name = return_turn_model_name(Config.UsedTurnModel) file_name = str(turn_model_name)+'_eval' turn_model_eval_file = open('Generated_Files/Turn_Model_Eval/'+file_name+'.txt', 'a+') if viz: file_name_viz = str(turn_model_name)+'_eval_'+str(len(ag.edges())-combination) turn_model_eval_viz_file = open('Generated_Files/Internal/'+file_name_viz+'.txt', 'w') else: turn_model_eval_viz_file = None counter = 0 metric_sum = 0 list_of_avg = [] number_of_combinations = comb(108, combination) while True: sub_ag = sample(ag.edges(), combination) shmu = SystemHealthMonitoringUnit.SystemHealthMonitoringUnit() shmu.setup_noc_shm(ag, copy.deepcopy(Config.TurnsHealth), False) for link in list(sub_ag): shmu.break_link(link, False) noc_rg = copy.deepcopy(Routing.generate_noc_route_graph(ag, shmu, Config.UsedTurnModel, False, False)) connectivity_metric = reachability_metric(ag, noc_rg, False) counter += 1 metric_sum += connectivity_metric # std = None list_of_avg.append(float(metric_sum)/counter) if len(list_of_avg) > 5000: list_of_avg.pop(0) std = stdev(list_of_avg) if std < 0.009: # turn_model_eval_file.write("STD of the last 5000 average samples is bellow 0.009\n") # turn_model_eval_file.write("Terminating the search!\n") del shmu del noc_rg break if viz: turn_model_eval_viz_file.write(str(float(metric_sum)/counter)+"\n") if counter >= number_of_combinations: del shmu del noc_rg break # print "#:"+str(counter)+"\t\tC.M.:"+str(connectivity_metric)+"\t\t avg:", \ # float(metric_sum)/counter, "\t\tstd:", std del shmu del noc_rg if counter > 0: avg_connectivity = float(metric_sum)/counter else: avg_connectivity = 0 turn_model_eval_file.write(str(len(ag.edges())-combination)+"\t\t"+str(avg_connectivity)+"\n") turn_model_eval_file.close() if viz: turn_model_eval_viz_file.close() return None