Ejemplo n.º 1
0
def gen_plot_data(data_file, is_tgs_only, x_label):
    from scripts.utils import load_csv

    raw_data = load_csv(data_file)

    duplicates = set()
    plots = dict()
    perf_fig = dict()
    for k in raw_data:

        parse_entry_info(k, is_tgs_only)

        # Handle repeated data
        key = (k['Precision'], k['stencil_name'],
               k['LIKWID performance counter'], k['mwdt'], k['method'],
               k['tgsl'], k['Global NX'], k['OpenMP Threads'])
        if key not in duplicates:
            duplicates.add(key)
        else:
            print("Repeated result at: %s" % (k['file_name']))
            continue

        init_plot_entry(plots, k)
        append_meas_data(plots, k)
        append_perf_data(perf_fig, k, x_label)

    del raw_data

    sort_perf_fig(perf_fig)
    sort_meas_fig(plots)

    return plots, perf_fig
Ejemplo n.º 2
0
def gen_plot_data(data_file, is_tgs_only, x_label):
    from scripts.utils import load_csv

    raw_data = load_csv(data_file)

    duplicates = set()
    plots = dict()
    perf_fig = dict()
    for k in raw_data:

        parse_entry_info(k, is_tgs_only)

        # Handle repeated data
        key = (
            k["Precision"],
            k["stencil_name"],
            k["LIKWID performance counter"],
            k["mwdt"],
            k["method"],
            k["tgsl"],
            k["Global NX"],
            k["OpenMP Threads"],
        )
        if key not in duplicates:
            duplicates.add(key)
        else:
            print ("Repeated result at: %s" % (k["file_name"]))
            continue

        init_plot_entry(plots, k)
        append_meas_data(plots, k)
        append_perf_data(perf_fig, k, x_label)

    del raw_data

    sort_perf_fig(perf_fig)
    sort_meas_fig(plots)

    return plots, perf_fig
Ejemplo n.º 3
0
def main():
    import sys
    from scripts.utils import get_stencil_num, load_csv
    from collections import OrderedDict

    raw_data = load_csv(sys.argv[1])

    req_fields = [('MStencil/s  MAX', float), ('Precision', int),
                  ('Global NX', int), ('Number of time steps', int),
                  ('Number of tests', int)]

    hw_ctr_fields = {
        '': [],
        'TLB': [('L1 DTLB miss rate sum', float)],
        'DATA': [('Load to Store ratio avg', float)],
        'L2': [('L2 data volume sum', float)],
        'L3': [('L3 data volume sum', float)],
        'MEM': [('Total Memory Transfer', float),
                ('Sustained Memory BW', float)],
        'ENERGY': [('Energy', float), ('Energy DRAM', float), ('Power', float),
                   ('Power DRAM', float)]
    }

    duplicates = set()
    meas_figs = dict()
    perf_fig = dict()
    for k in raw_data:

        # get processor name from the file names
        if (k['OpenMP Threads'] != ''):
            if (int(k['OpenMP Threads']) == 10):
                machine_name = 'ivb10'
            elif (int(k['OpenMP Threads']) == 18):
                machine_name = 'hw18'

        # Use single field to represent the performance
        if 'Total RANK0 MStencil/s MAX' in k.keys():
            if (k['Total RANK0 MStencil/s MAX'] != ''):
                k['MStencil/s  MAX'] = k['MWD main-loop RANK0 MStencil/s MAX']
        # temporary for deprecated format
        if 'RANK0 MStencil/s  MAX' in k.keys():
            if k['RANK0 MStencil/s  MAX'] != '':
                k['MStencil/s  MAX'] = k['RANK0 MStencil/s  MAX']

        # add stencil operator
        k['stencil'] = get_stencil_num(k)
        if k['stencil'] == 0:
            k['stencil_name'] = '25_pt_const'
        elif k['stencil'] == 1:
            k['stencil_name'] = '7_pt_const'
        elif k['stencil'] == 4:
            k['stencil_name'] = '25_pt_var'
        elif k['stencil'] == 5:
            k['stencil_name'] = '7_pt_var'
        elif k['stencil'] == 6:
            k['stencil_name'] = 'solar'

        # add the approach
        if (k['Time stepper orig name'] == 'Spatial Blocking'):
            k['method'] = 'Spt.blk.'
        elif (k['Time stepper orig name'] in ['PLUTO', 'Pochoir']):
            k['method'] = k['Time stepper orig name']
        elif (k['Time stepper orig name'] == 'Diamond'):
            if ('_tgs1_' in k['file_name']):
                k['method'] = '1WD'
            else:
                k['method'] = 'MWD'
        else:
            print("ERROR: Unknow time stepper")
            raise

        # add mwd type
        k['mwdt'] = 'none'
        if (k['method'] == 'MWD'):
            mwd = k['Wavefront parallel strategy'].lower()
            if ('fixed' in mwd) and ('relaxed' in mwd):
                k['mwdt'] = 'fers'
            elif ('fixed' in mwd):
                k['mwdt'] = 'fe'
            elif ('relaxed' in mwd):
                k['mwdt'] = 'rs'
            elif ('wavefront' in mwd):
                k['mwdt'] = 'block'

        # add precision information
        p = 1 if k['Precision'] in 'DP' else 0
        k['Precision'] = p

        # TLB measurement for LIKWID 4
        if 'L1 DTLB load miss rate avg' in k.keys():
            if k['L1 DTLB load miss rate avg'] != '':
                hw_ctr_fields['TLB'] = [('L1 DTLB load miss rate avg', float)]
                hw_ctr_labels['TLB'] = [('L1 DTLB load miss rate avg', 'tlb_',
                                         'tlb')]

        entry = {}
        # parse the general fileds' format
        for f in req_fields + hw_ctr_fields[k['LIKWID performance counter']]:
            try:
                entry[f[0]] = map(f[1], [k[f[0]]])[0]
            except:
                print(
                    "ERROR: results entry missing essential data at file:%s" %
                    (k['file_name']))
                print f[0]
                print k
                return

        #find repeated data
        key = (entry['Precision'], k['stencil_name'],
               k['LIKWID performance counter'], k['mwdt'], k['method'],
               entry['Global NX'])
        if key not in duplicates:
            duplicates.add(key)
        else:
            print("Repeated result at: %s" % (k['file_name']))
            continue

        # Initialize plot entry if does not exist for current data entry
#    for m,n in entry.iteritems(): print m,n
        measure_list = [
            'n', 'perf', 'total energy', 'tlb', 'mem bw', 'l2 bw', 'l3 bw',
            'mem vol', 'l2 vol', 'l3 vol', 'data', 'tgs', 'thx', 'thy', 'thz',
            'blk size', 'diam width', 'bs_z'
        ]
        plot_key = (entry['Precision'], k['stencil_name'],
                    k['LIKWID performance counter'])
        line_key = (k['mwdt'], k['method'])
        if plot_key not in meas_figs.keys():
            meas_figs[plot_key] = {}
        if line_key not in meas_figs[plot_key].keys():
            meas_figs[plot_key][line_key] = {meas: [] for meas in measure_list}

        # append the measurement data
        meas_figs[plot_key][line_key]['n'].append(entry['Global NX'])
        #    meas_figs[plot_key][line_key]['perf'].append(entry['MStencil/s  MAX']/1e3)
        N = entry['Global NX']**3 * entry['Number of time steps'] * entry[
            'Number of tests'] / 1e9
        # Memory
        if k['LIKWID performance counter'] == 'MEM':
            meas_figs[plot_key][line_key]['mem bw'].append(
                entry['Sustained Memory BW'] / 1e3)
            meas_figs[plot_key][line_key]['mem vol'].append(
                entry['Total Memory Transfer'] / N)
        # Energy
        elif k['LIKWID performance counter'] == 'ENERGY':
            entry['cpu energy pj/lup'] = entry['Energy'] / N
            entry['dram energy pj/lup'] = entry['Energy DRAM'] / N
            entry['total energy pj/lup'] = entry['cpu energy pj/lup'] + entry[
                'dram energy pj/lup']
            if (entry['total energy pj/lup'] < 3e3):
                #        entry['total energy pj/lup'] = 0
                meas_figs[plot_key][line_key]['total energy'].append(
                    entry['total energy pj/lup'])
            else:
                del meas_figs[plot_key][line_key]['n'][-1]
        # TLB
        elif k['LIKWID performance counter'] == 'TLB':
            meas_figs[plot_key][line_key]['tlb'].append(
                entry[hw_ctr_fields['TLB'][0][0]])
        # L2
        elif k['LIKWID performance counter'] == 'L2':
            meas_figs[plot_key][line_key]['l2 vol'].append(
                entry['L2 data volume sum'] / N)
        #L3
        elif k['LIKWID performance counter'] == 'L3':
            meas_figs[plot_key][line_key]['l3 vol'].append(
                entry['L3 data volume sum'] / N)
        #CPU
        elif k['LIKWID performance counter'] == 'DATA':
            meas_figs[plot_key][line_key]['data'].append(
                entry['Load to Store ratio avg'])
        #Diamond tiling data
        if (k['method'] == '1WD' or k['method'] == 'MWD'):
            meas_figs[plot_key][line_key]['diam width'].append(
                int(k['Intra-diamond width']))
            meas_figs[plot_key][line_key]['tgs'].append(
                int(k['Thread group size']))
            meas_figs[plot_key][line_key]['thx'].append(
                int(k['Threads along x-axis']))
            meas_figs[plot_key][line_key]['thy'].append(
                int(k['Threads along y-axis']))
            meas_figs[plot_key][line_key]['thz'].append(
                int(k['Threads along z-axis']))
            meas_figs[plot_key][line_key]['blk size'].append(
                int(k['Total cache block size (kiB)']) / 1024.0)
            meas_figs[plot_key][line_key]['bs_z'].append(
                int(k['Multi-wavefront updates']))

        # append the performance data
        plot_key = (entry['Precision'], k['stencil_name'])
        line_key = (k['mwdt'], k['method'])
        if plot_key not in perf_fig.keys():  # figure
            perf_fig[plot_key] = dict()

        perf_line = perf_fig[plot_key]
        if line_key not in perf_line.keys():  # line
            perf_line[line_key] = dict()

        perf_point = perf_line[line_key]
        nx = entry['Global NX']
        if nx not in perf_point.keys():  # points
            perf_point[nx] = [entry['MStencil/s  MAX'] / 1e3]
        else:
            perf_point[nx].append(entry['MStencil/s  MAX'] / 1e3)

    del raw_data

    #sort performance results
    for k, v in perf_fig.iteritems():
        for k2, v2 in perf_fig[k].iteritems():
            perf_line = perf_fig[k][k2]
            perf_fig[k][k2] = OrderedDict(
                sorted(perf_fig[k][k2].iteritems(), key=lambda x: x[0]))
#  for k,v in perf_fig.iteritems():
#    print(k, "##########")
#    for k2,v2 in perf_fig[k].iteritems():
#      print(k2,v2)

#sort the plot lines
    for p in meas_figs:
        for l in meas_figs[p]:
            pl = meas_figs[p][l]
            #remove unused fields
            empty = []
            for key, val in pl.iteritems():
                if (val == []):
                    empty.append(key)
            for key in empty:
                del pl[key]
            lines = []
            [lines.append(pl[val]) for val in measure_list if val in pl.keys()]

            lines = sorted(zip(*lines))
            idx = 0
            for val in measure_list:
                if (val in pl.keys()):
                    if (pl[val]):
                        pl[val] = [x[idx] for x in lines]
                        idx = idx + 1


#  for m,n in meas_figs.iteritems():
#    print "##############",m
#    for i,j in n.iteritems():
#      print i,j

    plot_all(perf_fig, meas_figs, machine_name)
def main():
  import sys
  from scripts.utils import get_stencil_num, load_csv
  from collections import OrderedDict

  raw_data = load_csv(sys.argv[1])


  req_fields = [('MStencil/s  MAX', float), ('Precision', int), ('Global NX', int), ('Number of time steps', int), ('Number of tests', int)]

  hw_ctr_fields = {
                    '':[],
                    'TLB':[('L1 DTLB miss rate sum', float)],
                    'DATA':[('Load to Store ratio avg', float)],
                    'L2':[('L2 data volume sum', float)],
                    'L3':[('L3 data volume sum', float)],
                    'MEM':[('Total Memory Transfer', float),('Sustained Memory BW', float)],
                    'ENERGY':[('Energy', float), ('Energy DRAM', float), ('Power',float), ('Power DRAM', float)]}


  duplicates = set()
  meas_figs = dict()
  perf_fig = dict()
  for k in raw_data:

    # get processor name from the file names
    if(k['OpenMP Threads']!=''):
      if(int(k['OpenMP Threads']) == 10):
        machine_name = 'ivb10'
      elif(int(k['OpenMP Threads']) == 18):
        machine_name = 'hw18'

    # Use single field to represent the performance
    if 'Total RANK0 MStencil/s MAX' in k.keys():
      if(k['Total RANK0 MStencil/s MAX']!=''):
        k['MStencil/s  MAX'] = k['MWD main-loop RANK0 MStencil/s MAX']
    # temporary for deprecated format
    if 'RANK0 MStencil/s  MAX' in k.keys():
      if k['RANK0 MStencil/s  MAX']!='':
        k['MStencil/s  MAX'] = k['RANK0 MStencil/s  MAX']


    # add stencil operator
    k['stencil'] = get_stencil_num(k)
    if   k['stencil'] == 0:
      k['stencil_name'] = '25_pt_const'
    elif k['stencil'] == 1:
      k['stencil_name'] = '7_pt_const'
    elif k['stencil'] == 4:
      k['stencil_name']  = '25_pt_var'
    elif k['stencil'] == 5:
      k['stencil_name']  = '7_pt_var'
    elif k['stencil'] == 6:
      k['stencil_name']  = 'solar'


    # add the approach
    if(k['Time stepper orig name'] == 'Spatial Blocking'):
      k['method'] = 'Spt.blk.'
    elif(k['Time stepper orig name'] in ['PLUTO', 'Pochoir']):
      k['method'] = k['Time stepper orig name']
    elif(k['Time stepper orig name'] == 'Diamond'):
      if('_tgs1_' in k['file_name']):
        k['method'] = '1WD'
      else:
        k['method'] = 'MWD'
    else:
      print("ERROR: Unknow time stepper")
      raise

    # add mwd type
    k['mwdt']='none'
    if(k['method'] == 'MWD'):
      mwd = k['Wavefront parallel strategy'].lower()
      if('fixed' in mwd) and ('relaxed' in mwd):
        k['mwdt'] = 'fers'
      elif('fixed' in mwd):
        k['mwdt'] = 'fe'
      elif('relaxed' in mwd):
        k['mwdt'] = 'rs'
      elif('wavefront' in mwd):
        k['mwdt'] = 'block'


    # add precision information
    p = 1 if k['Precision'] in 'DP' else 0
    k['Precision'] = p


    # TLB measurement for LIKWID 4
    if 'L1 DTLB load miss rate avg' in k.keys():
      if k['L1 DTLB load miss rate avg']!='':
        hw_ctr_fields['TLB'] =  [('L1 DTLB load miss rate avg', float)]
        hw_ctr_labels['TLB'] =  [('L1 DTLB load miss rate avg', 'tlb_', 'tlb')]

    entry = {}
    # parse the general fileds' format
    for f in req_fields + hw_ctr_fields[k['LIKWID performance counter']]:
      try:
        entry[f[0]] = map(f[1], [k[f[0]]] )[0]
      except:
        print("ERROR: results entry missing essential data at file:%s"%(k['file_name']))
        print f[0]
        print k
        return

    #find repeated data
    key = (entry['Precision'], k['stencil_name'], k['LIKWID performance counter'], k['mwdt'], k['method'], entry['Global NX'])
    if key not in duplicates:
      duplicates.add(key)
    else:
      print("Repeated result at: %s"%(k['file_name']))
      continue


    # Initialize plot entry if does not exist for current data entry
#    for m,n in entry.iteritems(): print m,n
    measure_list = ['n', 'perf', 'total energy', 'tlb', 'mem bw', 'l2 bw', 'l3 bw', 'mem vol', 'l2 vol', 'l3 vol', 'data', 'tgs', 'thx', 'thy', 'thz', 'blk size', 'diam width', 'bs_z']
    plot_key = (entry['Precision'], k['stencil_name'], k['LIKWID performance counter'])
    line_key = (k['mwdt'], k['method'])
    if plot_key not in meas_figs.keys():
      meas_figs[plot_key] = {}
    if line_key not in meas_figs[plot_key].keys():
      meas_figs[plot_key][line_key] = {meas:[] for meas in measure_list}

    # append the measurement data
    meas_figs[plot_key][line_key]['n'].append(entry['Global NX'])
#    meas_figs[plot_key][line_key]['perf'].append(entry['MStencil/s  MAX']/1e3)
    N = entry['Global NX']**3 * entry['Number of time steps'] * entry['Number of tests']/1e9
    # Memory
    if k['LIKWID performance counter'] == 'MEM':
      meas_figs[plot_key][line_key]['mem bw'].append(entry['Sustained Memory BW']/1e3)
      meas_figs[plot_key][line_key]['mem vol'].append(entry['Total Memory Transfer']/N)
    # Energy
    elif k['LIKWID performance counter'] == 'ENERGY':
      entry['cpu energy pj/lup'] = entry['Energy']/N
      entry['dram energy pj/lup'] = entry['Energy DRAM']/N
      entry['total energy pj/lup'] = entry['cpu energy pj/lup'] + entry['dram energy pj/lup']
      if (entry['total energy pj/lup'] < 3e3):
#        entry['total energy pj/lup'] = 0
        meas_figs[plot_key][line_key]['total energy'].append(entry['total energy pj/lup'])
      else:
        del meas_figs[plot_key][line_key]['n'][-1]
    # TLB
    elif k['LIKWID performance counter'] == 'TLB':
      meas_figs[plot_key][line_key]['tlb'].append(entry[ hw_ctr_fields['TLB'][0][0] ])
    # L2
    elif k['LIKWID performance counter'] == 'L2':
      meas_figs[plot_key][line_key]['l2 vol'].append(entry['L2 data volume sum']/N)
    #L3
    elif k['LIKWID performance counter'] == 'L3':
      meas_figs[plot_key][line_key]['l3 vol'].append(entry['L3 data volume sum']/N)
    #CPU
    elif k['LIKWID performance counter'] == 'DATA':
      meas_figs[plot_key][line_key]['data'].append(entry['Load to Store ratio avg'])
    #Diamond tiling data
    if(k['method'] == '1WD' or k['method'] == 'MWD'):
      meas_figs[plot_key][line_key]['diam width'].append(int(k['Intra-diamond width']))
      meas_figs[plot_key][line_key]['tgs'].append(int(k['Thread group size']))
      meas_figs[plot_key][line_key]['thx'].append(int(k['Threads along x-axis']))
      meas_figs[plot_key][line_key]['thy'].append(int(k['Threads along y-axis']))
      meas_figs[plot_key][line_key]['thz'].append(int(k['Threads along z-axis']))
      meas_figs[plot_key][line_key]['blk size'].append(int(k['Total cache block size (kiB)'])/1024.0)
      meas_figs[plot_key][line_key]['bs_z'].append(int(k['Multi-wavefront updates']))

    # append the performance data
    plot_key = (entry['Precision'], k['stencil_name'])
    line_key = (k['mwdt'], k['method'])
    if plot_key not in perf_fig.keys(): # figure
      perf_fig[plot_key] = dict()

    perf_line = perf_fig[plot_key]
    if line_key not in perf_line.keys(): # line
      perf_line[line_key] = dict()

    perf_point = perf_line[line_key]
    nx = entry['Global NX']
    if nx not in perf_point.keys(): # points
      perf_point[nx] = [entry['MStencil/s  MAX']/1e3]
    else:
      perf_point[nx].append(entry['MStencil/s  MAX']/1e3)


  del raw_data

  #sort performance results
  for k,v in perf_fig.iteritems():
    for k2,v2 in perf_fig[k].iteritems():
      perf_line = perf_fig[k][k2]
      perf_fig[k][k2] = OrderedDict(sorted(perf_fig[k][k2].iteritems(), key=lambda x:x[0]))
#  for k,v in perf_fig.iteritems():
#    print(k, "##########")
#    for k2,v2 in perf_fig[k].iteritems():
#      print(k2,v2)


  #sort the plot lines
  for p in meas_figs:
    for l in meas_figs[p]:
      pl = meas_figs[p][l]
      #remove unused fields
      empty = []
      for key, val in pl.iteritems():
        if(val==[]):
          empty.append(key)
      for key in empty:
          del pl[key]
      lines = []
      [lines.append(pl[val]) for val in measure_list if val in pl.keys()]

      lines = sorted(zip(*lines))
      idx=0
      for val in measure_list:
        if(val in pl.keys()):
          if(pl[val]):
            pl[val] = [x[idx] for x in lines]
            idx = idx+1

#  for m,n in meas_figs.iteritems():
#    print "##############",m
#    for i,j in n.iteritems():
#      print i,j

  plot_all(perf_fig, meas_figs, machine_name)