コード例 #1
0
def reference_waveform(adp, waveform):
    program = DSProgDB.get_prog(adp.metadata[ADPMetadata.Keys.DSNAME])
    dssim = DSProgDB.get_sim(program.name)
    dsinfo = DSProgDB.get_info(program.name)
    ref_waveforms = get_reference_waveforms(program, dssim)

    reference = ref_waveforms[waveform.variable]
    return program, dsinfo, dssim, reference
コード例 #2
0
def print_summary(dev, adp, rmse):
    program = DSProgDB.get_prog(adp.metadata[ADPMetadata.Keys.DSNAME])
    dssim = DSProgDB.get_sim(program.name)
    dsinfo = DSProgDB.get_info(program.name)

    runtime = dev.time_constant / adp.tau * dssim.sim_time
    bandwidth = (1.0 / dev.time_constant) * adp.tau
    power = energymodel.compute_power(adp, bandwidth)
    energy = runtime * power

    print("--------    general -------------")
    print("runtime = %f ms" % (runtime * 1000))
    print("power    = %f mW" % (power * 1e3))
    print("energy  = %f uJ" % (energy * 1e6))
    print("quality = %f %%" % rmse)

    print("------------ metadata ----------------")
    print(adp.metadata)
    print("------------ lgraph ----------------")
    by_block = {'fanout':[],'adc':[],'dac':[],'mult':[], 'integ':[], \
                'extout':[],'extin':[],'cin':[],'cout':[],'tin':[],'tout':[]}

    total_blocks = 0
    for cfg in adp.configs:
        if cfg.inst.block in by_block:
            by_block[cfg.inst.block].append(cfg.mode)
        total_blocks += 1

    total_conns = len(list(adp.conns))

    for block_name, modes in by_block.items():
        if len(modes) > 0:
            print("%s = %d modes=%s" % (block_name, len(modes), set(modes)))

    print("total blocks = %d" % total_blocks)
    print("total conns = %d" % total_conns)

    print("------------ lscale  ----------------")
    scale_factors = []
    injected_vars = []
    for cfg in adp.configs:
        for stmt in cfg.stmts:
            if stmt.type == adplib.ConfigStmtType.CONSTANT:
                scale_factors.append(stmt.scf)
            if stmt.type == adplib.ConfigStmtType.PORT:
                scale_factors.append(stmt.scf)
            if stmt.type == adplib.ConfigStmtType.EXPR:
                for scf in stmt.scfs:
                    scale_factors.append(scf)
                for inj in stmt.injs:
                    injected_vars.append(inj)

    print("tau=%f" % (adp.tau))
    print("scf total = %d" % len(scale_factors))
    print("scf uniq = %d" % len(set(scale_factors)))
    print("inj total = %d" % len(injected_vars))
    print("inj uniq = %d" % len(set(injected_vars)))
コード例 #3
0
def plot_preamble_realtime(entry):
    # compute reference using information from first element
    output = list(entry.outputs())[0]
    palette = sns.color_palette()
    ax = plt.subplot(1, 1, 1)
    info = DSProgDB.get_info(entry.program)
    title = info.name
    ax.set_xlabel('time (ms)', fontsize=18)
    ax.tick_params(labelsize=16)
    ax.set_ylabel(info.units, fontsize=18)
    #ax.set_xticklabels([])
    #ax.set_yticklabels([])
    #ax.set_title(title,fontsize=20)
    ax.grid(False)
    return ax
コード例 #4
0
def visualize(db):
    header = [
        'description', 'observation', 'time', 'diffeqs', 'funcs', 'nonlinear'
    ]
    desc = 'dynamical system benchmarks used in evaluation. $\dagger$ these benchmarks '
    table = common.Table('Benchmarks', desc, 'bmarksumm', '|c|lccccc|')
    table.two_column = True
    bool_to_field = {True: 'yes', False: 'no'}
    table.set_fields(header)
    table.horiz_rule()
    table.header()
    table.horiz_rule()
    for bmark in table.benchmarks():
        bmark_name = bmark
        if 'heat1d' in bmark:
            bmark_name = 'heat1d'

        if not DSProgDB.has_prog(bmark):
            print("skipping %s... no info" % bmark)
            continue

        info = DSProgDB.get_info(bmark)
        prog = DSProgDB.get_prog(bmark)
        dssim = DSProgDB.get_sim(bmark)
        n_diffeqs = 0
        n_funcs = 0
        for v, bnd in prog.bindings():
            if bnd.op == op.OpType.INTEG:
                n_diffeqs += 1
            else:
                n_funcs += 1
        print(info)
        entry = {
            'description': info.description,
            'observation': info.observation,
            'diffeqs': n_diffeqs,
            'funcs': n_funcs,
            'time': str(dssim.sim_time) + " su",
            'nonlinear': bool_to_field[info.nonlinear]
        }
        table.data(bmark, entry)
    table.horiz_rule()

    table.write(common.get_path('bmarks.tbl'))
コード例 #5
0
def plot_preamble(entry, TREF, YREF):
    # compute reference using information from first element
    output = list(entry.outputs())[0]
    palette = sns.color_palette()
    ax = plt.subplot(1, 1, 1)
    info = DSProgDB.get_info(entry.program)
    title = info.name
    ax.set_xlabel('simulation time', fontsize=32)
    ax.set_ylabel(info.units, fontsize=32)
    ax.set_xticklabels([])
    ax.set_yticklabels([])
    #ax.set_title(title,fontsize=20)
    ax.set_xlim((min(TREF), max(TREF)))
    margin = (max(YREF) - min(YREF)) * 0.1
    lb = min(YREF) - margin
    ub = max(YREF) + margin
    ax.set_ylim((lb, ub))
    ax.grid(False)

    ax.plot(TREF,YREF,label='reference',
            linestyle='-', \
            linewidth=3, \
            color="#E74C3C")
    return ax