def parseStats(stats_file, config, router_config_file, link_config_file,
               routers, int_links, ext_links, number_of_virtual_networks,
               vcs_per_vnet, buffers_per_data_vc, buffers_per_control_vc,
               ni_flit_size_bits):

    # Open the stats.txt file and parse it to for the required numbers
    # and the number of routers.
    try:
        stats_handle = open(stats_file, 'r')
        stats_handle.close()
    except IOError:
        print("Failed to open ", stats_file, " for reading")
        exit(-1)

    # Now parse the stats
    pattern = "sim_seconds"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    assert len(lines) >= 1

    ## Assume that the first line is the one required
    [l1, l2, l3] = lines[0].partition(" ")
    l4 = l3.strip().partition(" ")
    simulation_length_in_seconds = float(l4[0])

    # Initialize DSENT with a configuration file
    dsent.initialize(router_config_file)

    # Compute the power consumed by the routers
    for router in routers:
        computeRouterPowerAndArea(router, stats_file, config, int_links,
                                  ext_links, number_of_virtual_networks,
                                  vcs_per_vnet, buffers_per_data_vc,
                                  buffers_per_control_vc, ni_flit_size_bits)

    # Finalize DSENT
    dsent.finalize()

    # Initialize DSENT with a configuration file
    dsent.initialize(link_config_file)

    # Compute the power consumed by the links
    for link in int_links:
        computeLinkPower(link, stats_file, config,
                         simulation_length_in_seconds)
    for link in ext_links:
        computeLinkPower(link, stats_file, config,
                         simulation_length_in_seconds)

    # Finalize DSENT
    dsent.finalize()
Exemplo n.º 2
0
def parseStats(stats_file, config, router_config_file, link_config_file,
               routers, int_links, ext_links, number_of_virtual_networks,
               vcs_per_vnet, buffers_per_data_vc, buffers_per_control_vc,
               ni_flit_size_bits):

    # Open the stats.txt file and parse it to for the required numbers
    # and the number of routers.
    try:
        stats_handle = open(stats_file, 'r')
        stats_handle.close()
    except IOError:
        print("Failed to open ", stats_file, " for reading")
        exit(-1)

    # Now parse the stats
    pattern = "sim_seconds"
    lines = string.split(subprocess.check_output(
                ["grep", pattern, stats_file]), '\n', -1)
    assert len(lines) >= 1

    ## Assume that the first line is the one required
    [l1,l2,l3] = lines[0].partition(" ")
    l4 = l3.strip().partition(" ")
    simulation_length_in_seconds = float(l4[0])

    # Initialize DSENT with a configuration file
    dsent.initialize(router_config_file)

    # Compute the power consumed by the routers
    for router in routers:
        computeRouterPowerAndArea(router, stats_file, config, int_links,
                                  ext_links, number_of_virtual_networks,
                                  vcs_per_vnet, buffers_per_data_vc,
                                  buffers_per_control_vc, ni_flit_size_bits)

    # Finalize DSENT
    dsent.finalize()

    # Initialize DSENT with a configuration file
    dsent.initialize(link_config_file)

    # Compute the power consumed by the links
    for link in int_links:
        computeLinkPower(link, stats_file, config,
                         simulation_length_in_seconds)
    for link in ext_links:
        computeLinkPower(link, stats_file, config,
                         simulation_length_in_seconds)

    # Finalize DSENT
    dsent.finalize()
    # l4 = l3.strip().partition(" ")
    # simulation_length_in_seconds = float(l4[0])
    simulation_length_in_seconds1 = float(0.170707)

    # Initialize DSENT with a configuration file
    dsent.initialize(router_config_file)

    # Compute the power consumed by the routers
    for router in routers:
        computeRouterPowerAndArea(router, stats_file, config, int_links,
                                  ext_links, number_of_virtual_networks,
                                  vcs_per_vnet, buffers_per_data_vc,
                                  buffers_per_control_vc, ni_flit_size_bits)

    # Finalize DSENT
    dsent.finalize()

    # Initialize DSENT with a configuration file
    dsent.initialize(link_config_file)

    # Compute the power consumed by the links
    for link in int_links:
        computeLinkPower(link, stats_file, config,
                         simulation_length_in_seconds1)
    for link in ext_links:
        computeLinkPower(link, stats_file, config,
                         simulation_length_in_seconds1)

    # Finalize DSENT
    dsent.finalize()
Exemplo n.º 4
0
def parseStats(stats_dir, config, router_config_file, link_config_file,
               attached_router_id, number_of_virtual_networks, vcs_per_vnet,
               buffers_per_vc, flit_size_bits, booksim_config):

    # Open the stats.txt file and parse it to for the required numbers
    # and the number of routers.
    stats_file = stats_dir + "/stats.txt"
    booksim_stats_file = stats_dir + "/booksimstats.json"
    try:
        stats_handle = open(stats_file, 'r')
        stats_handle.close()
    except IOError:
        print("Failed to open ", stats_file, " for reading")
        exit(-1)

    # Now parse the stats
    pattern = "sim_seconds"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    assert len(lines) >= 1

    ## Assume that the first line is the one required
    [l1, l2, l3] = lines[0].partition(" ")
    l4 = l3.strip().partition(" ")
    simulation_length_in_seconds = float(l4[0])

    # get clock cycle time in ps
    cycle_time_in_ps = getClock("system.ruby.clk_domain", config)
    cycles = simulation_length_in_seconds * 1000000000000 / cycle_time_in_ps

    # Get router and link activities
    # router buffer reads: injection
    pattern = "router_buffer_reads"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    assert len(lines) >= 2
    [l1, l2, l3] = lines[0].partition(" ")
    router_act = [int(s) for s in l3.split() if s.isdigit()]
    inject_rate = [act / cycles for act in router_act]
    # inject link activiy
    pattern = "inject_link_activity"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    assert len(lines) >= 2
    [l1, l2, l3] = lines[0].partition(" ")
    inject_act = [int(s) for s in l3.split() if s.isdigit()]
    inject_link_rate = [act / cycles for act in inject_act]
    # eject link activiy
    pattern = "eject_link_activity"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    assert len(lines) >= 2
    [l1, l2, l3] = lines[0].partition(" ")
    eject_act = [int(s) for s in l3.split() if s.isdigit()]
    eject_link_rate = [act / cycles for act in eject_act]
    # internal link activiy
    pattern = "int_link_activity"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    assert len(lines) >= 2
    [l1, l2, l3] = lines[0].partition(" ")
    int_link_act = [int(s) for s in l3.split() if s.isdigit()]
    int_link_rate = [act / cycles for act in int_link_act]

    # Open the gem5booksim.cfg file and parse it to for the off routers.
    try:
        booksim_config_handle = open(booksim_config, 'r')
        booksim_config_handle.close()
    except IOError:
        print("Failed to open ", stats_file, " for reading")
        exit(-1)
    # get off routers
    pattern = "off_routers"
    lines = shell(["grep", pattern, booksim_config])
    off_routers = []
    if len(lines) >= 1:
        l1 = re.findall('\d+', lines)
        off_routers = map(int, l1)
    #print off_routers
    pattern = "network.flov_hops"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    flov_hops = [int(s) for s in lines[0].split() if s.isdigit()]
    flov_hops = sum(flov_hops)
    #print flov_hops
    pattern = "network.hops"
    lines = string.split(
        subprocess.check_output(["grep", pattern, stats_file]), '\n', -1)
    hops = [int(s) for s in lines[0].split() if s.isdigit()]
    hops = sum(hops)
    #print hops

    # Initialize DSENT with a configuration file
    dsent.initialize(router_config_file)

    # Compute the power consumed by the routers
    with open(booksim_stats_file) as json_file:
        booksim_stats = json.load(json_file)
    router_dynamic_power = 0.0
    router_static_power = 0.0
    for (r, inj) in enumerate(inject_rate):
        print('Router {}:'.format(r))
        if r == 0:
            inj = flov_hops / cycles + hops / cycles
        else:
            inj = 0
        rpower = computeRouterPowerAndArea(
            r, stats_file, config, number_of_virtual_networks, vcs_per_vnet,
            buffers_per_vc, attached_router_id, flit_size_bits, inj)
        assert rpower[12][0] == 'Total dynamic power: '
        assert rpower[13][0] == 'Total leakage power: '
        router_dynamic_power += rpower[12][1]
        on_percent = booksim_stats["routers"]["router_{}".format(r)]["power-on-percentile"]
        print(' on percent: {}'.format(on_percent))
        router_static_power += rpower[13][1] * on_percent
        print('')

    # Finalize DSENT
    dsent.finalize()

    # Initialize DSENT with a configuration file
    dsent.initialize(link_config_file)

    # Compute the power consumed by the links
    link_dynamic_power = 0.0
    link_static_power = 0.0
    for (i, act_factor) in enumerate(inject_link_rate):
        link = "inject_link#" + str(i)
        lpower = computeLinkPower(link, stats_file, config,
                                  simulation_length_in_seconds, flit_size_bits,
                                  act_factor)
        link_dynamic_power += lpower[0][1]
        link_static_power += lpower[1][1]

    for (i, act_factor) in enumerate(eject_link_rate):
        link = "eject_link#" + str(i)
        lpower = computeLinkPower(link, stats_file, config,
                                  simulation_length_in_seconds, flit_size_bits,
                                  act_factor)
        link_dynamic_power += lpower[0][1]
        link_static_power += lpower[1][1]

    for (i, act_factor) in enumerate(int_link_rate):
        link = "internal_link#" + str(i)
        lpower = computeLinkPower(link, stats_file, config,
                                  simulation_length_in_seconds, flit_size_bits,
                                  act_factor)
        link_dynamic_power += lpower[0][1]
        link_static_power += lpower[1][1]

    # Finalize DSENT
    dsent.finalize()

    dynamic_power = router_dynamic_power + link_dynamic_power
    static_power = router_static_power + link_static_power
    dynamic_energy = dynamic_power * simulation_length_in_seconds
    static_energy = static_power * simulation_length_in_seconds
    print "total router dynamic power: " + str(router_dynamic_power)
    print "total router static power: " + str(router_static_power)
    print "total link dynamic power: " + str(link_dynamic_power)
    print "total link static power: " + str(link_static_power)
    print "network dynamic power: " + str(dynamic_power)
    print "network static power: " + str(static_power)
    print "\nNetwork Energy:"
    print "    Dynamic Energy: " + str(dynamic_energy)
    print "    Static Energy:  " + str(static_energy)

    return dynamic_power, static_power, dynamic_energy, static_energy