Пример #1
0
def run_simulator(runtime, tg, ag, shmu, noc_rg, critical_rg, noncritical_rg,
                  logging):
    """
    prepares and runs the simulator
    :param runtime: duration of which the user wants to run the program in cycles
    :param ag: architecture graph
    :param shmu: system health monitoring unit
    :param noc_rg: noc routing graph
    :param logging: logging file
    :return: None
    """
    print("===========================================")
    print("SETTING UP THE SIMULATOR...")
    env = simpy.Environment()
    print("SETTING UP counter-threshold MODULE...")
    if Config.classification_method == "counter_threshold":

        counter_threshold = CounterThreshold.CounterThreshold(
            Config.fault_counter_threshold, Config.health_counter_threshold,
            Config.intermittent_counter_threshold)
    elif Config.classification_method == "machine_learning":
        counter_threshold = MachineLearning.MachineLearning(
            Config.fault_counter_threshold,  # Rene's addition
            Config.health_counter_threshold * 3,
            Config.intermittent_counter_threshold)
    else:
        raise ValueError("Unknown Classification Method!! Check config file")

    # the fault_time_dictionary looks like this:
    # fault_time_dictionary[fault_time] = (fault_location, fault_type)
    fault_time_dict = {}
    schedule_length = Scheduling_Functions.find_schedule_make_span(ag)
    if Config.EventDrivenFaultInjection:
        if Config.fault_injection_method == "random":
            fault_time_dict = copy.deepcopy(
                generate_random_fault_time_dict(runtime, shmu.SHM))
        elif Config.fault_injection_method == "from_file":
            fault_time_dict = generate_fault_time_dict_from_file()

        env.process(
            fault_event(env, ag, shmu, noc_rg, schedule_length,
                        fault_time_dict, counter_threshold, logging))

    print("SETTING UP ROUTERS AND PES...")
    for node in ag.nodes():
        # print node, AG.node[node]["Scheduling"]
        env.process(
            processor_sim(env, ag, shmu, node, schedule_length,
                          fault_time_dict, counter_threshold, logging))
        env.process(
            router_sim(env, ag, shmu, node, schedule_length, fault_time_dict,
                       counter_threshold, logging))

    print("SETTING UP LINKS...")
    for link in ag.edges():
        # print link, AG.edge[link[0]][link[1]]["Scheduling"]
        env.process(
            link_sim(env, ag, shmu, link, schedule_length, fault_time_dict,
                     counter_threshold, logging))

    env.process(sim_report(env, ag, shmu, counter_threshold))
    print("STARTING SIMULATION...")
    env.run()
    iteration = 1
    time_passed = env.now
    del env

    while time_passed < Config.ProgramRunTime:
        print("===========================================")
        Config.ProgramRunTime -= time_passed
        shmu.signal_reconfiguration = False
        tg, ag = copy.deepcopy(
            system_reconfiguration(tg, ag, shmu, noc_rg, critical_rg,
                                   noncritical_rg, iteration, logging))
        print("SETTING UP THE SIMULATOR...")
        env = simpy.Environment()

        # fault_time_dict = {}
        schedule_length = Scheduling_Functions.find_schedule_make_span(ag)
        if Config.EventDrivenFaultInjection:
            fault_time_dict = copy.deepcopy(
                update_fault_time_dict(time_passed, fault_time_dict))
            env.process(
                fault_event(env, ag, shmu, noc_rg, schedule_length,
                            fault_time_dict, counter_threshold, logging))
        print("SETTING UP ROUTERS AND PES...")
        for node in ag.nodes():
            # print node, AG.node[node]["Scheduling"]
            env.process(
                processor_sim(env, ag, shmu, node, schedule_length,
                              fault_time_dict, counter_threshold, logging))
            env.process(
                router_sim(env, ag, shmu, node, schedule_length,
                           fault_time_dict, counter_threshold, logging))
        print("SETTING UP LINKS...")
        for link in ag.edges():
            # print link, AG.edge[link[0]][link[1]]["Scheduling"]
            env.process(
                link_sim(env, ag, shmu, link, schedule_length, fault_time_dict,
                         counter_threshold, logging))
        print("SETTING UP SIM MONITORS...")
        env.process(sim_report(env, ag, shmu, counter_threshold))

        print("RESTARTING SIMULATION...")
        print("REMAINING SIM TIME:", Config.ProgramRunTime)
        env.run()
        iteration += 1
        time_passed = env.now
        del env
    print("SIMULATION FINISHED...")
    print("SYSTEM DEGRADATION:", shmu.system_degradation)
    counter_threshold.report(len(ag.nodes()), len(ag.edges()))
    Counter_Threshold_Viz.counter_threshold_viz(ag, counter_threshold)
    Scheduling_Reports.report_scheduling_memory_usage(ag)
    return None
Пример #2
0
def run_simulator(runtime, ag, shmu, noc_rg, logging):
    """
    prepares and runs the simulator
    :param runtime: duration of which the user wants to run the program in cycles
    :param ag: architecture graph
    :param shmu: system health monitoring unit
    :param noc_rg: noc routing graph
    :param logging: logging file
    :return: None
    """
    print "==========================================="
    print "SETTING UP THE SIMULATOR..."
    env = simpy.Environment()
    print "SETTING UP counter-threshold MODULE..."
    if Config.classification_method == "counter_threshold":

        counter_threshold = CounterThreshold.CounterThreshold(
            Config.fault_counter_threshold, Config.health_counter_threshold,
            Config.intermittent_counter_threshold)
    elif Config.classification_method == "machine_learning":
        counter_threshold = MachineLearning.MachineLearning(
            Config.fault_counter_threshold,  # Rene's addition
            Config.health_counter_threshold * 3,
            Config.intermittent_counter_threshold)
    else:
        raise ValueError("Unknown Classification Method!! Check config file")

    fault_time_dict = {}
    fault_time = 0
    schedule_length = Scheduling_Functions.FindScheduleMakeSpan(ag)
    if Config.EventDrivenFaultInjection:
        time_until_next_fault = numpy.random.normal(Config.MTBF,
                                                    Config.SD4MTBF)
        fault_time += time_until_next_fault
        while fault_time < runtime:
            fault_location, fault_type = SHMU_Functions.RandomFaultGeneration(
                shmu.SHM)
            fault_time_dict[float(
                "{0:.1f}".format(fault_time))] = (fault_location, fault_type)
            time_until_next_fault = numpy.random.normal(
                Config.MTBF, Config.SD4MTBF)
            fault_time += time_until_next_fault

        env.process(
            fault_event(env, ag, shmu, noc_rg, schedule_length,
                        fault_time_dict, counter_threshold, logging))

    print "SETTING UP ROUTERS AND PES..."
    for node in ag.nodes():
        # print node, AG.node[node]["Scheduling"]
        env.process(
            processor_sim(env, ag, node, ag.node[node]['PE'].Scheduling,
                          schedule_length, fault_time_dict, counter_threshold,
                          logging))
        env.process(
            router_sim(env, ag, node, ag.node[node]['Router'].Scheduling,
                       schedule_length, fault_time_dict, counter_threshold,
                       logging))

    print "SETTING UP LINKS..."
    for link in ag.edges():
        # print link, AG.edge[link[0]][link[1]]["Scheduling"]
        env.process(
            link_sim(env, ag, link, ag.edge[link[0]][link[1]]["Scheduling"],
                     schedule_length, fault_time_dict, counter_threshold,
                     logging))

    env.process(sim_report(env, ag, counter_threshold))
    print "STARTING SIMULATION..."
    env.run(until=runtime)
    print "SIMULATION FINISHED..."
    counter_threshold.report(len(ag.nodes()), len(ag.edges()))
    Counter_Threshold_Viz.counter_threshold_viz(ag, counter_threshold)
    Scheduling_Reports.report_scheduling_memory_usage(ag)
    return None
Пример #3
0
def run_simulator(runtime, tg, ag, shmu, noc_rg, critical_rg, noncritical_rg, logging):
    """
    prepares and runs the simulator
    :param runtime: duration of which the user wants to run the program in cycles
    :param ag: architecture graph
    :param shmu: system health monitoring unit
    :param noc_rg: noc routing graph
    :param logging: logging file
    :return: None
    """
    print "==========================================="
    print "SETTING UP THE SIMULATOR..."
    env = simpy.Environment()
    print "SETTING UP counter-threshold MODULE..."
    if Config.classification_method == "counter_threshold":

        counter_threshold = CounterThreshold.CounterThreshold(Config.fault_counter_threshold,
                                                              Config.health_counter_threshold,
                                                              Config.intermittent_counter_threshold)
    elif Config.classification_method == "machine_learning":
        counter_threshold = MachineLearning.MachineLearning(Config.fault_counter_threshold,     # Rene's addition
                                                            Config.health_counter_threshold*3,
                                                            Config.intermittent_counter_threshold)
    else:
        raise ValueError("Unknown Classification Method!! Check config file")

    # the fault_time_dictionary looks like this:
    # fault_time_dictionary[fault_time] = (fault_location, fault_type)
    fault_time_dict = {}
    schedule_length = Scheduling_Functions.find_schedule_make_span(ag)
    if Config.EventDrivenFaultInjection:
        if Config.fault_injection_method == "random":
            fault_time_dict = copy.deepcopy(generate_random_fault_time_dict(runtime, shmu.SHM))
        elif Config.fault_injection_method == "from_file":
            fault_time_dict = generate_fault_time_dict_from_file()

        env.process(fault_event(env, ag, shmu, noc_rg, schedule_length, fault_time_dict,
                                counter_threshold, logging))

    print "SETTING UP ROUTERS AND PES..."
    for node in ag.nodes():
        # print node, AG.node[node]["Scheduling"]
        env.process(processor_sim(env, ag, shmu, node, schedule_length,
                                  fault_time_dict, counter_threshold,  logging))
        env.process(router_sim(env, ag, shmu, node, schedule_length,
                               fault_time_dict, counter_threshold, logging))

    print "SETTING UP LINKS..."
    for link in ag.edges():
        # print link, AG.edge[link[0]][link[1]]["Scheduling"]
        env.process(link_sim(env, ag, shmu, link, schedule_length,
                             fault_time_dict, counter_threshold, logging))

    env.process(sim_report(env, ag, shmu, counter_threshold))
    print "STARTING SIMULATION..."
    env.run()
    iteration = 1
    time_passed = env.now
    del env

    while time_passed < Config.ProgramRunTime:
        print "==========================================="
        Config.ProgramRunTime -= time_passed
        shmu.signal_reconfiguration = False
        tg, ag = copy.deepcopy(system_reconfiguration(tg, ag, shmu, noc_rg, critical_rg, noncritical_rg,
                                                      iteration, logging))
        print "SETTING UP THE SIMULATOR..."
        env = simpy.Environment()

        # fault_time_dict = {}
        schedule_length = Scheduling_Functions.find_schedule_make_span(ag)
        if Config.EventDrivenFaultInjection:
            fault_time_dict = copy.deepcopy(update_fault_time_dict(time_passed, fault_time_dict))
            env.process(fault_event(env, ag, shmu, noc_rg, schedule_length, fault_time_dict,
                                    counter_threshold, logging))
        print "SETTING UP ROUTERS AND PES..."
        for node in ag.nodes():
            # print node, AG.node[node]["Scheduling"]
            env.process(processor_sim(env, ag, shmu, node, schedule_length,
                                      fault_time_dict, counter_threshold,  logging))
            env.process(router_sim(env, ag, shmu, node, schedule_length,
                                   fault_time_dict, counter_threshold, logging))
        print "SETTING UP LINKS..."
        for link in ag.edges():
            # print link, AG.edge[link[0]][link[1]]["Scheduling"]
            env.process(link_sim(env, ag, shmu, link, schedule_length,
                                 fault_time_dict, counter_threshold, logging))
        print "SETTING UP SIM MONITORS..."
        env.process(sim_report(env, ag, shmu, counter_threshold))

        print "RESTARTING SIMULATION..."
        print "REMAINING SIM TIME:", Config.ProgramRunTime
        env.run()
        iteration += 1
        time_passed = env.now
        del env
    print "SIMULATION FINISHED..."
    print "SYSTEM DEGRADATION:", shmu.system_degradation
    counter_threshold.report(len(ag.nodes()), len(ag.edges()))
    Counter_Threshold_Viz.counter_threshold_viz(ag, counter_threshold)
    Scheduling_Reports.report_scheduling_memory_usage(ag)
    return None