Exemple #1
0
def _dump_to_visitor(visitor, roots=None):
    # New stats
    def dump_group(group):
        for stat in group.getStats():
            stat.visit(visitor)
        for n, g in group.getStatGroups().items():
            visitor.beginGroup(n)
            dump_group(g)
            visitor.endGroup()

    if roots:
        # New stats from selected subroots.
        for root in roots:
            for p in root.path_list():
                visitor.beginGroup(p)
            dump_group(root)
            for p in reversed(root.path_list()):
                visitor.endGroup()
    else:
        # Legacy stats
        for stat in stats_list:
            stat.visit(visitor)

        # New stats starting from root.
        dump_group(Root.getInstance())
Exemple #2
0
def dump(stats_desc="", root=None):
    '''Dump all statistics data to the registered outputs'''

    now = m5.curTick()
    global lastDump
    assert lastDump <= now
    new_dump = lastDump != now
    lastDump = now

    # Don't allow multiple global stat dumps in the same tick. It's
    # still possible to dump a multiple sub-trees.
    if not new_dump and root is None:
        return

    # Only prepare stats the first time we dump them in the same tick.
    if new_dump:
        _m5.stats.processDumpQueue()
        # Notify new-style stats group that we are about to dump stats.
        sim_root = Root.getInstance()
        if sim_root:
            sim_root.preDumpStats()
        prepare()

    for output in outputList:
        if output.valid():
            output.begin(stats_desc)
            _dump_to_visitor(output, root=root)
            output.end()
Exemple #3
0
def create_xml(frequency):
    from m5 import options
    import os

    global stat_strings
    stat_strings = []
    _m5.stats.processDumpQueue()
    sim_root = Root.getInstance()
    if sim_root:
        sim_root.preDumpStats()
        #predumping does nothing unless overriden
        prepare(
        )  #prepare for scalar stats does nothing: statistic.h - class statstor.prepare()
    for output in outputList:
        if output.valid():
            stat_strings.append(output.begin())
            _dump_to_visitor(output, None)
            stat_strings.append(output.end())

    m5_stats_file = os.path.join(options.outdir, options.stats_file)
    m5_config_file = os.path.join(options.outdir, options.dump_config)
    mcpat_output_path = os.path.join(options.mcpat_out, options.mcpat_testname)

    if not os.path.isdir(mcpat_output_path):
        os.mkdir(mcpat_output_path)

    #TODO jimmy change these stats from hardcoded to params
    fr = [4E9 / 1E6]
    i_f = os.path.join(mcpat_output_path, "serial_mp.xml")

    generate_xml(m5_stats_file, m5_config_file, i_f, stat_strings, \
                True, voltage=1.4, frequency=fr, temperature=380.0, \
                device_type=options.mcpat_device_type)
Exemple #4
0
def _dump_to_visitor(visitor, root=None):
    global stat_strings
    # Legacy stats
    if root is None:
        for stat in stats_list:
            stat_strings.append(stat.visit(visitor))

    # New stats
    def dump_group(group):
        global stat_strings
        for stat in group.getStats():
            stat_strings.append(stat.visit(visitor))

        for n, g in group.getStatGroups().items():
            visitor.beginGroup(n)  #visitor is type output
            dump_group(g)
            visitor.endGroup()

    if root is not None:
        for p in root.path_list():
            visitor.beginGroup(p)
    dump_group(root if root is not None else Root.getInstance())
    if root is not None:
        for p in reversed(root.path_list()):
            visitor.endGroup()
Exemple #5
0
def dump(roots=None):
    '''Dump all statistics data to the registered outputs'''

    all_roots = []
    if roots is not None:
        all_roots.extend(roots)
    global global_dump_roots
    all_roots.extend(global_dump_roots)

    now = m5.curTick()
    global lastDump
    assert lastDump <= now
    new_dump = lastDump != now
    lastDump = now

    # Don't allow multiple global stat dumps in the same tick. It's
    # still possible to dump a multiple sub-trees.
    if not new_dump and not all_roots:
        return

    # Only prepare stats the first time we dump them in the same tick.
    if new_dump:
        _m5.stats.processDumpQueue()
        # Notify new-style stats group that we are about to dump stats.
        sim_root = Root.getInstance()
        if sim_root:
            sim_root.preDumpStats()
        prepare()

    for output in outputList:
        if isinstance(output, JsonOutputVistor):
            if not all_roots:
                output.dump(Root.getInstance())
            else:
                output.dump(all_roots)
        else:
            if output.valid():
                output.begin()
                _dump_to_visitor(output, roots=all_roots)
                output.end()
def reset():
    '''Reset all statistics to the base state'''

    # call reset stats on all SimObjects
    root = Root.getInstance()
    if root:
        for obj in root.descendants(): obj.resetStats()

    # call any other registered stats reset callbacks
    for stat in stats_list:
        stat.reset()

    internal.stats.processResetQueue()
Exemple #7
0
def reset():
    '''Reset all statistics to the base state'''

    # call reset stats on all SimObjects
    root = Root.getInstance()
    if root:
        root.resetStats()

    # call any other registered legacy stats reset callbacks
    for stat in stats_list:
        stat.reset()

    _m5.stats.processResetQueue()
Exemple #8
0
def reset():
    '''Reset all statistics to the base state'''

    # call reset stats on all SimObjects
    root = Root.getInstance()
    if root:
        for obj in root.descendants(): obj.resetStats()

    # call any other registered stats reset callbacks
    for stat in stats_list:
        stat.reset()

    internal.stats.processResetQueue()
Exemple #9
0
def dump(root=None, exit=False):
    '''Dump all statistics data to the registered outputs'''
    from m5 import options

    now = m5.curTick()
    global lastDump
    global numDump

    assert lastDump <= now
    global stat_strings
    stat_strings = []
    new_dump = lastDump != now
    lastDump = now

    # Don't allow multiple global stat dumps in the same tick. It's
    # still possible to dump a multiple sub-trees.
    if not new_dump and root is None:
        return

    numDump += 1

    if new_dump:
        _m5.stats.processDumpQueue()
        sim_root = Root.getInstance()
        if sim_root:
            sim_root.preDumpStats()
        prepare()

    for output in outputList:
        if output.valid():
            output.begin()
            _dump_to_visitor(output, root=root)
            output.end()

    # max_instr = options.power_profile_instrs
    max_dump = options.power_profile_duration

    print("Num Dumps: ", numDump)

    if (numDump == max_dump or exit):
        print("Ending after " + str(numDump) + " datapoints")
        sys.exit()
Exemple #10
0
def _dump_to_visitor(visitor, root=None):
    # Legacy stats
    if root is None:
        for stat in stats_list:
            stat.visit(visitor)

    # New stats
    def dump_group(group):
        for stat in group.getStats():
            stat.visit(visitor)

        for n, g in group.getStatGroups().items():
            visitor.beginGroup(n)
            dump_group(g)
            visitor.endGroup()

    if root is not None:
        for p in root.path_list():
            visitor.beginGroup(p)
    dump_group(root if root is not None else Root.getInstance())
    if root is not None:
        for p in reversed(root.path_list()):
            visitor.endGroup()
Exemple #11
0
def _visit_groups(visitor, root=None):
    if root is None:
        root = Root.getInstance()
    for group in root.getStatGroups().values():
        visitor(group)
        _visit_groups(visitor, root=group)
Exemple #12
0
def isRoot(obj):
    from m5.objects import Root
    return obj and obj is Root.getInstance()
def isRoot(obj):
    from m5.objects import Root
    return obj and obj is Root.getInstance()
Exemple #14
0
def dump_verilog(root=None, exit=False):
    print("******************DUMP_VERILOG******************")
    '''Dump all statistics data to the registered outputs'''
    from m5 import options

    now = m5.curTick()
    global lastDump
    global numDump
    global init_ncsim
    global lastVoltage
    global lastCurrent
    global runtime_begin_profile
    global committedInstrs
    global profiling
    global lv
    assert lastDump <= now
    global stat_strings
    stat_strings = []
    new_dump = lastDump != now
    lastDump = now

    # Don't allow multiple global stat dumps in the same tick. It's
    # still possible to dump a multiple sub-trees.
    # if not new_dump and root is None:
    #     return 0

    if (options.mcpat_enable):
        if ((options.power_profile_start != -1
             and now >= options.power_profile_start) or runtime_begin_profile):
            mcpat.set_flags(options.mcpat_use_fg_pg, \
                options.mcpat_scale_factor)

            # profiling = True
            # numDump += 1

            new_dump = True
            if new_dump:
                _m5.stats.processDumpQueue()
                sim_root = Root.getInstance()
                if sim_root:
                    sim_root.preDumpStats()
                    #predumping does nothing unless overriden
                prepare(
                )  #prepare for scalar stats does nothing: statistic.h - class statstor.prepare()
            for output in outputList:
                if output.valid():
                    stat_strings.append(output.begin())
                    _dump_to_visitor(output, root=root)
                    stat_strings.append(output.end())

            #print("".join(stat_strings))
            #sys.exit(1)

            # Initialilze the Verilog Sim:
            power = 0
            resistance = 0
            voltage = 0
            current = 0
            mp_v = vpi_shm.mp_get_voltage_set()
            mp_f = []
            for i in range(vpi_shm.mp_get_ncores()):
                mp_f.append(vpi_shm.mp_get_freq(i))
            if (options.ncverilog_enable):
                if init_ncsim:
                    # Run an Initial McPAT stats run with 1.0v
                    mcpat.m5_to_mcpat(stat_strings,\
                        options.stats_read_from_file, mp_v, mp_f, \
                        380.0, options.mcpat_device_type)
                    resistance = mcpat.get_last_r(mp_v, \
                        options.mcpat_use_fg_pg, \
                        options.mcpat_scale_factor)
                    current = mcpat.get_last_i(mp_v, \
                        options.mcpat_use_fg_pg, \
                        options.mcpat_scale_factor)
                    power = mcpat.get_last_p(mp_v, \
                        options.mcpat_use_fg_pg, \
                        options.mcpat_scale_factor)
                    # Run Init and warmup PowerSupply
                    vpi_shm.initialize(options.mcpat_testname)
                    for i in range(int(options.ncverilog_warmup)):
                        vpi_shm.set_driver_signals(current, 0)
                        lv = vpi_shm.get_voltage()
                        lastVoltage = lv
                        lastCurrent = vpi_shm.get_current()
                        vpi_shm.ack_supply()
                    init_ncsim = False
                else:
                    if options.ncverilog_feedback:
                        mcpat.m5_to_mcpat(stat_strings,\
                            options.stats_read_from_file, lv, mp_f, \
                            380.0, options.mcpat_device_type)
                        resistance = mcpat.get_last_r(lv, \
                            options.mcpat_use_fg_pg, \
                            options.mcpat_scale_factor)
                        current = mcpat.get_last_i(lv, \
                            options.mcpat_use_fg_pg, \
                            options.mcpat_scale_factor)
                        power = mcpat.get_last_p(lv, \
                            options.mcpat_use_fg_pg, \
                            options.mcpat_scale_factor)
                    else:
                        mcpat.m5_to_mcpat(stat_strings,\
                            options.stats_read_from_file, mp_v, mp_f, \
                            380.0, options.mcpat_device_type)
                        resistance = mcpat.get_last_r(mp_v, \
                            options.mcpat_use_fg_pg, \
                            options.mcpat_scale_factor)
                        current = mcpat.get_last_i(mp_v, \
                            options.mcpat_use_fg_pg, \
                            options.mcpat_scale_factor)
                        power = mcpat.get_last_p(mp_v, \
                            options.mcpat_use_fg_pg, \
                            options.mcpat_scale_factor)
                    vpi_shm.set_driver_signals(current, 0)
                    lv = vpi_shm.get_voltage()
                    lastVoltage = lv
                    lastCurrent = vpi_shm.get_current()
                    vpi_shm.ack_supply()

            else:
                mcpat.m5_to_mcpat(stat_strings,\
                    options.stats_read_from_file, 1.4, [4000], \
                    380.0, options.mcpat_device_type)

            # max_dump = options.power_profile_duration
            # max_instr = options.power_profile_instrs
            # if(numDump == max_dump or exit or committedInstrs >= max_instr):
            #     mcpat.dump()
            #     runtime_begin_profile = False
            #     print("Ending after "+str(numDump)+
            #           " stat dumps")
            #     # Clean up simulation:
            #     if(options.ncverilog_enable):
            #         current = mcpat.get_last_i(mp_v)
            #         vpi_shm.set_driver_signals(current, 1)
            #         lastVoltage=vpi_shm.get_voltage()
            #         lastCurrent=vpi_shm.get_current()
            #         vpi_shm.ack_supply()
            #     sys.exit()
    else:
        if new_dump:
            _m5.stats.processDumpQueue()
            sim_root = Root.getInstance()
            if sim_root:
                sim_root.preDumpStats()
            prepare()

        for output in outputList:
            if output.valid():
                output.begin()
                _dump_to_visitor(output, root=root)
                output.end()

    power_ret = mcpat.get_last_p(voltage=1.4,
                                 power_gating=True,
                                 scale_factor=1.0)
    if power_ret is None:
        return 0
    return power_ret