parameters: (roof_data, band_labels)
return_statement: return peak_bandwidths
docstring: Get multi-level bandwidth peaks - Implementation from ERT:
      https://bitbucket.org/berkeleylab/cs-roofline-toolkit
docstring_summary: Get multi-level bandwidth peaks - Implementation from ERT:
      https://bitbucket.org/berkeleylab/cs-roofline-toolkit
docstring_tokens: Get multi - level bandwidth peaks - Implementation from ERT : https : // bitbucket . org / berkeleylab / cs - roofline - toolkit
function: def get_peak_bandwidth(roof_data, band_labels):
      """
      Get multi-level bandwidth peaks - Implementation from ERT:
      https://bitbucket.org/berkeleylab/cs-roofline-toolkit
      """
      ref_intensity = 0
      work_set = []
      bandwidth_data = []
  
      # Read bandwidth raw data
      for element in roof_data:
          intensity = element.ops_per_set
          if ref_intensity == 0:
              ref_intensity = intensity
          if intensity != ref_intensity:
              continue
          work_set.append(element.working_set)
          total_bytes = element.total_bytes / GIGABYTE
          bandwidth_data.append(element.counter.get(total_bytes))
  
      fraction = 1.05
      samples = 10000
      bandwidth_data = flatten_list(bandwidth_data)
  
      max_bandwidth = max(bandwidth_data)
      begin = bandwidth_data.index(max_bandwidth)
  
      work_set = work_set[begin:]
      bandwidth_data = bandwidth_data[begin:]
      # min_bandwidth = min(bandwidth_data)
  
      dband = max_bandwidth / float(samples - 1)
  
      counts = samples * [0]
      totals = samples * [0.0]
  
      work_set, bandwidth_data = smooth(work_set, bandwidth_data)
  
      for i in range(0, samples):
          cband = i * dband
          for bandwidth in bandwidth_data:
              if bandwidth >= cband / fraction and bandwidth <= cband * fraction:
                  totals[i] += bandwidth
                  counts[i] += 1
  
      band_list = [[1000 * max_bandwidth, 1000]]
  
      maxc = -1
      maxi = -1
  
      for i in range(samples - 3, 1, -1):
          if counts[i] > 10:
              if counts[i] > maxc:
                  maxc = counts[i]
                  maxi = i
          else:
              if maxc > 1:
                  value = float(totals[maxi]) / max(1, counts[maxi])
                  if 1.20 * value < float(band_list[-1][0]) / band_list[-1][1]:
                      band_list.append([totals[maxi], counts[maxi]])
                  else:
                      band_list[-1][0] += totals[maxi]
                      band_list[-1][1] += counts[maxi]
              maxc = -1
              maxi = -1
  
      band_info_list = ["DRAM"]
      cache_num = len(band_list) - 1
  
      for cache in range(1, cache_num + 1):
          band_info_list = ["L%d" % (cache_num + 1 - cache)] + band_info_list
  
      peak_bandwidths = []
      band_info_list = [e for e in band_info_list if e in band_labels]
  
      for (band, band_info) in zip(band_list, band_info_list):
          band_info = band_info + " GB/s"
          peak_bandwidths.append([float(band[0] / band[1]), band_info])
  
      return peak_bandwidths
function_tokens: def get_peak_bandwidth ( roof_data , band_labels ) : ref_intensity = 0 work_set = [ ] bandwidth_data = [ ] # Read bandwidth raw data for element in roof_data : intensity = element . ops_per_set if ref_intensity == 0 : ref_intensity = intensity if intensity != ref_intensity : continue work_set . append ( element . working_set ) total_bytes = element . total_bytes / GIGABYTE bandwidth_data . append ( element . counter . get ( total_bytes ) ) fraction = 1.05 samples = 10000 bandwidth_data = flatten_list ( bandwidth_data ) max_bandwidth = max ( bandwidth_data ) begin = bandwidth_data . index ( max_bandwidth ) work_set = work_set [ begin : ] bandwidth_data = bandwidth_data [ begin : ] # min_bandwidth = min(bandwidth_data) dband = max_bandwidth / float ( samples - 1 ) counts = samples * [ 0 ] totals = samples * [ 0.0 ] work_set , bandwidth_data = smooth ( work_set , bandwidth_data ) for i in range ( 0 , samples ) : cband = i * dband for bandwidth in bandwidth_data : if bandwidth >= cband / fraction and bandwidth <= cband * fraction : totals [ i ] += bandwidth counts [ i ] += 1 band_list = [ [ 1000 * max_bandwidth , 1000 ] ] maxc = - 1 maxi = - 1 for i in range ( samples - 3 , 1 , - 1 ) : if counts [ i ] > 10 : if counts [ i ] > maxc : maxc = counts [ i ] maxi = i else : if maxc > 1 : value = float ( totals [ maxi ] ) / max ( 1 , counts [ maxi ] ) if 1.20 * value < float ( band_list [ - 1 ] [ 0 ] ) / band_list [ - 1 ] [ 1 ] : band_list . append ( [ totals [ maxi ] , counts [ maxi ] ] ) else : band_list [ - 1 ] [ 0 ] += totals [ maxi ] band_list [ - 1 ] [ 1 ] += counts [ maxi ] maxc = - 1 maxi = - 1 band_info_list = [ "DRAM" ] cache_num = len ( band_list ) - 1 for cache in range ( 1 , cache_num + 1 ) : band_info_list = [ "L%d" % ( cache_num + 1 - cache ) ] + band_info_list peak_bandwidths = [ ] band_info_list = [ e for e in band_info_list if e in band_labels ] for ( band , band_info ) in zip ( band_list , band_info_list ) : band_info = band_info + " GB/s" peak_bandwidths . append ( [ float ( band [ 0 ] / band [ 1 ] ) , band_info ] ) return peak_bandwidths