Beispiel #1
0
def build_board_summary(profile):
    desc = "board characteristics"
    table = common.Table('HDACv2 Board Characteristics', \
                         desc, 'hwboard','|ccc|cccc|ccc|ccc|ccc|',
                         benchmarks=False)
    fields = ['property', \
              'value']
    table.set_fields(fields)

    row = {}
    row['property'] = 'time constant'
    row['value'] = '%d hz' % profile['time_constant']
    table.data(None, row)

    row = {}
    row['property'] = 'connections'
    row['value'] = '%d' % profile['conns']
    table.data(None, row)

    row = {}
    row['property'] = 'external inputs'
    row['value'] = profile['ext_inputs']
    table.data(None, row)

    row = {}
    row['property'] = 'external outputs'
    row['value'] = profile['ext_outputs']
    table.data(None, row)
    table.write(common.get_path('hwboard.tbl'))
def to_lscale_table(circuits,models):
  desc = "statistics for \lscale compilation pass"
  table = common.Table('Circuit Configurations', \
                       desc, 'circ-lscale','|c|ccc|ccc|cc|')

  hdr1 = [
    '','','','',
    '\multicolumn{3}{c|}{scale factors}',
    '\multicolumn{2}{c|}{injected vars}'
  ]
  hdr2 = [
    'benchmarks',
    'DQM','AQM','max freq','time',
    'total','unique',
    'total','unique',
  ]
  fields = [
    'mdpe',
    'mape',
    'max freq',
    'time constant',
    'scale vars',
    'unique scale vars',
    'free vars',
    'unique free vars'

  ]
  table.set_fields(fields)
  table.horiz_rule()
  table.raw(hdr1);
  table.raw(hdr2);
  table.horiz_rule()

  for bmark in table.benchmarks():
    if not bmark in circuits:
      continue

    summary = average_scale_factor_count(circuits[bmark], \
                                         models[bmark])
    row = {}
    row['mdpe'] = "%.3f" % (summary['mdpe'])
    row['mape'] = "%.3f" % (summary['mape'])
    row['max freq'] = "%dk" % int(summary['bandwidth'])
    row['time constant'] = "%.2f" % summary['tau']
    row['scale vars'] = "%d" % summary['scvars']
    row['unique scale vars'] = "%d" % summary['scvals']
    row['free vars'] = "%d" % summary['injvars']
    row['unique free vars'] = "%d" % summary['injvals']
    table.data(bmark,row)

  table.horiz_rule()
  table.write(common.get_path('circuit-lscale.tbl'))
def to_lgraph_table(circuits):
  to_header = {
    'tile_out': 'route',
    'tile_in': 'route',
    'chip_out': 'route',
    'chip_in': 'route',
    'ext_chip_out': 'cout',
    'ext_chip_in': 'cin',
    'tile_dac':'dac',
    'tile_adc':'adc',
    'lut':'lut',
    'fanout': 'fan',
    'multiplier': 'mul',
    'integrator': 'int',
    'conns': 'connections'
  }
  desc = 'analog chip configuration statistics'
  table = common.Table('Circuit Configurations', \
                       desc, 'circ-lgraph','|c|c|ccccccccc|c|')
  fields = ['blocks','int','mul', \
                    'fan','adc','dac','lut', \
                    'cout', 'cin', \
                    'route','connections']
  table.set_fields(fields)
  table.horiz_rule()
  table.header()
  table.horiz_rule()
  for bmark in table.benchmarks():
    row = {}
    if not bmark in circuits:
      continue

    data = average_comp_count(circuits[bmark])
    for f in fields:
      row[f] = 0

    for key,value in data['blocks'].items():
      row[to_header[key]] += value

    row[to_header['conns']] += data['conns']
    row['blocks'] = data['total']
    for f,v in row.items():
      row[f] = "%d" % v

    table.data(bmark,row)

  table.horiz_rule()
  table.write(common.get_path('circuit-lgraph.tbl'))
Beispiel #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'))
Beispiel #5
0
def to_runtime_table(summary):
    def format_runtime(r):
        mean, std = r
        if mean is None:
            return "n/a"

        if not std == 0.0:
            return "%.2f $\pm$ %.2f s" % (mean, std)
        else:
            return "%.2f s $\pm$ %.2f" % (mean, std)

    desc = "compilation time, broken down by compilation pass"
    table = common.Table('Compilation Times', \
                         desc, 'comptime','|c|ccc|')
    table.set_fields(['lgraph', 'lscale', 'srcgen'])
    table.horiz_rule()
    table.header()
    table.horiz_rule()
    for bmark in table.benchmarks():
        if not bmark in summary:
            continue

        row = {}
        if not 'lgraph' in summary[bmark]:
            row['lgraph'] = '-'
        else:
            row['lgraph'] = format_runtime(summary[bmark]['lgraph'])

        if not 'lscale' in summary[bmark]:
            row['lscale'] = '-'
        else:
            row['lscale'] = format_runtime(summary[bmark]['lscale'])

        if not 'srcgen' in summary[bmark]:
            row['srcgen'] = '-'
        else:
            row['srcgen'] = format_runtime(summary[bmark]['srcgen'])

        table.data(bmark, row)

    table.horiz_rule()
    table.write(common.get_path('compile-time.tbl'))
Beispiel #6
0
def visualize(db):
    data = common.get_data(db, series_type='program', subset='extended')
    desc = "performance, energy and quality for HDACv2 Board"
    table = common.Table("Results", desc, "tbl:performance", \
                         layout = "|c|c|ccc|")
    table.two_column = False
    header = [
            'runtime', \
            'power', \
            'energy', \
            '% rmse' \
    ]
    table.set_fields(header)
    table.horiz_rule()
    table.header()
    table.horiz_rule()
    for ser in common.Plot.benchmarks():
        print(ser)
        if data.has_series(ser):
            fields = [
                'runtime', 'energy', 'quality', 'quality_variance', 'model'
            ]
            result = data.get_data(ser, fields)
            runtime, energy, quality, quality_variance, model = result
            idx = np.argmin(quality)

            row = {}
            pars = util.unpack_model(model[idx])
            row['runtime'] = "%.2f ms" % (runtime[idx] * 1e3)
            row['power'] = "%.2f $\mu$W" % (energy[idx] * 1e6)
            row['energy'] = "%.2f $\mu$J" % (energy[idx] * runtime[idx] * 1e6)
            row['% rmse'] = "%.2f" % quality[idx]
            #row['% rmse'] = "%.4f $\pm$ %.4f" \
            #                 % (np.mean(quality),np.std(quality))
            #row['minimum digital snr'] = "%f" % dig_error
            #row['minimum analog snr'] = "%f" % ana_error
            row['bandwidth'] = "%dkhz" % int(pars['bandwidth_khz'])

            table.data(ser, row)
    table.horiz_rule()
    table.write(common.get_path('quality-energy-runtime.tbl'))
def visualize(db):
    data = common.get_data(db, series_type='program', executed_only=False)
    desc = "performance, energy and quality for HDACv2 Board"
    table = common.Table("Results", desc, "tbl:performance", \
                         layout = "|c|c|cc|")
    table.two_column = False
    header = [
            'runtime', \
            'power', \
            'energy'
    ]
    table.set_fields(header)
    table.horiz_rule()
    table.header()
    table.horiz_rule()
    for ser in common.Plot.benchmarks():
        if data.has_series(ser):
            fields = ['runtime', 'energy', 'model']
            result = data.get_data(ser, fields)
            runtime, power, model = result

            row = {}
            n = len(runtime)
            mu, sig = np.mean(runtime), np.std(runtime)
            row['runtime'] = "%.2f $\pm$ %.2f ms" % (mu * 1e3, sig * 1e3)
            mu, sig = np.mean(power), np.std(power)
            row['power'] = "%.2f $\pm$ %.2f $\mu$W" % (mu * 1e6, sig * 1e6)
            energy = list(map(lambda i: runtime[i] * power[i], range(n)))
            mu, sig = np.mean(energy), np.std(energy)
            row['energy'] = "%.2f $\pm$ %.2f $\mu$J" % (mu * 1e6, sig * 1e6)
            pars = util.unpack_model(model[0])
            row['bandwidth'] = "%dkhz" % int(pars['bandwidth_khz'])

            table.data(ser, row)
    table.horiz_rule()
    table.write(common.get_path('energy-runtime.tbl'))
Beispiel #8
0
def build_block_summary(profile):
    desc = "summaries of computational blocks available on device"
    table = common.Table('HDACv2 Board Block Summaries', \
                         desc, 'hwblocks','|ccc|cc|cc|cc|cc|',
                         benchmarks=False)
    table.two_column = True
    fields = ['block', \
              'type', \
              'count', \
              'analog_in', \
              'analog_out', \
              'digital_in', \
              'digital_out', \
              'data_const', \
              'data_expr', \
              'modes', \
              'desc'
    ]

    cat = [
        '', '', '', '\multicolumn{2}{c|}{analog}',
        '\multicolumn{2}{c|}{digital}', '\multicolumn{2}{c|}{data}', '', ''
    ]
    table.set_fields(fields)
    table.horiz_rule()
    hdr = ['block', \
              'type', \
              'count', \
              'in', \
              'out', \
              'in', \
              'out', \
              'const', \
              'expr', \
              'modes', \
              'desc'
    ]
    table.raw(cat)
    table.raw(hdr)
    table.horiz_rule()
    for block in profile['blocks']:
        prof = profile['blocks'][block]

        if not block in to_header:
            continue

        row = {}
        row['block'] = "%s" % to_header[block]
        row['type'] = "%s" % prof['type']
        row['count'] = "%d" % prof['count']
        row['analog_in'] = prof['analog_inputs']
        row['analog_out'] = prof['analog_outputs']
        row['digital_in'] = prof['digital_inputs']
        row['digital_out'] = prof['digital_outputs']
        row['data_const'] = prof['data_const']
        row['data_expr'] = prof['data_expr']
        row['modes'] = prof['modes']
        row['desc'] = to_desc[block]
        table.data(None, row)
        '''
    if block == 'multiplier':
      for comp_mode,data in prof['scale_modes'].items():
        row = dict(row)
        row['compute mode'] = comp_mode
        row['function'] = to_expr[(block,comp_mode)]
        row['scale modes'] = data['scale_modes']

        if data['oprange_min'] == data['oprange_max']:
          row['operating bound'] = "%.1f" % (data['oprange_min'])
        else:
          row['operating bound'] = "%.1f-%.1f" \
                                 % (data['oprange_min'], \
                                    data['oprange_max'])
        if data['coeff_min'] == data['coeff_max']:
          row['gain'] = "%.1f x" % data['coeff_min']
        else:
          row['gain'] = "%.1f-%.1f x" \
                        % (data['coeff_min'], \
                           data['coeff_max'])
        table.data(None,row)

    else:
      comp_modes = list(prof['scale_modes'].keys())
      row['compute mode'] = "%d" % len(comp_modes)
      data = prof['scale_modes'][comp_modes[0]]
      row['scale_modes'] = data['scale_modes']
      if (block,None) in to_expr:
        row['function'] = to_expr[(block,None)]
      else:
        row['function'] = '$z_0 = x_0$'

      row['scale modes'] = data['scale_modes']
      if data['oprange_min'] == data['oprange_max']:
          row['operating bound'] = "%.1f" % (data['oprange_min'])
      else:
        row['operating bound'] = "%.1f-%.1f" \
                               % (data['oprange_min'], \
                                  data['oprange_max'])
      if data['coeff_min'] == data['coeff_max']:
        row['gain'] = "%.1f x" % data['coeff_min']
      else:
        row['gain'] = "%.1f -%.1f x" \
                      % (data['coeff_min'], \
                         data['coeff_max'])
      table.data(None,row)
      if block == "integrator":
        row = dict(map(lambda f: (f,""),fields))
        row['function'] =to_expr[('integrator2',None)]
        table.data(None,row)
    '''

    table.horiz_rule()
    table.write(common.get_path('hwblocks.tbl'))
def get_table(obj_tag,obj):
  db = modellib.ModelDB(calib_obj=obj)
  by_ident = {}
  by_block = {}
  for model in db.get_all():
    ident = "%s-%s-%s" % (model.block, \
                          "comp-mode" \
                          if model.block == "fanout" \
                          else model.comp_mode, \
                          model.scale_mode)

    if not ident in by_ident:
      by_ident[ident] = {}
    if not model.block in by_block:
      by_block[model.block] = []
    if not model.loc in by_ident[ident]:
      by_ident[ident][model.loc] = {}

    by_ident[ident][model.loc][(model.port,model.handle)] = model
    if not ident in by_block[model.block]:
      by_block[model.block].append(ident)

  print("build table")
  desc = "delta model summary"
  table = common.Table('Delta Model Summary for %s' % obj_tag, \
                       desc, 'delta-%s' % obj_tag,'|c|cc|cccc|', \
                       benchmarks=False)
  fields = [
    'block',
    'mode',
    'alpha',
    'gamma',
    'beta',
    'error'
  ]
  table.set_fields(fields)
  table.horiz_rule()
  table.header()
  table.horiz_rule()

  for block,idents in by_block.items():
    if block == "tile_in" or \
       block == "tile_out" or \
       block == "chip_in" or \
       block == "lut" or \
       block == "chip_out" or \
       block == "ext_chip_out" or \
       block == "ext_chip_in" or \
       block == "ext_chip_analog_in":
      continue

    block_name = block.replace("_","\_")
    for idx,ident in enumerate(idents):
      model = list(list(by_ident[ident].values())[0].values())[0]
      dists = make_dist(ident,by_ident[ident])
      row = {}
      if idx == 0:
        row['block'] = block_name
      else:
        row['block'] = ''

      row['mode'] = get_mode(model)
      if "alpha" in dists:
        m,s = dists['alpha']
        row['alpha'] = "$%.2f \pm %.2f$" % (m,s)
      else:
        row['alpha'] = ''

      if "beta" in dists:
        m,s = dists['beta']
        row['beta'] = "$%.2f \pm %.2f$" % (m,s)
      else:
        row['beta'] = ''

      if "gamma" in dists:
        m,s = dists['gamma']
        row['gamma'] = "$%.2f \pm %.2f$" % (m,s)
      else:
        row['gamma'] = ''

      if "error" in dists:
        m,s = dists['error']
        row['error'] = "$%.3f \pm %.2f$" % (m,s)
      else:
        row['error'] = ''


      table.data(None,row)

  table.horiz_rule()
  table.write(common.get_path('delta-models-%s.tbl' % obj.value))