parameters: (op_data, ai_data, index=None)
return_statement: return hotspots
docstring: Get the hotspots information
docstring_summary: Get the hotspots information
docstring_tokens: Get the hotspots information
function: def get_hotspots_integer(op_data, ai_data, index=None):
      """
      Get the hotspots information
      """
      import itertools
  
      marker = itertools.cycle(("o", ",", "^", "+", "*", ">", "<"))
      if "type" not in op_data or "type" not in ai_data:
          return []
  
      op_data_type = op_data["type"]
  
      op_type = None
      if "cpu_roofline" in op_data_type:
          op_type = "cpu"
      if "gpu_roofline" in op_data_type:
          op_type = "gpu"
  
      if index is None:
          index = RANK_INDEX
  
      if "ranks" in op_data:
          op_data = op_data["ranks"][index]
      if "ranks" in ai_data:
          ai_data = ai_data["ranks"][index]
  
      op_graph_data = op_data["graph"]
      ai_graph_data = ai_data["graph"]
      hotspots = []
  
      # avg_runtime = 1.0
      # max_runtime = 0.0
      # max_length = min([len(op_graph_data), len(ai_graph_data)])
      all_runtime = []
  
      def get_runtime(_data, extra=[]):
          opts = ["runtime", "elapsed"] + extra
          for opt in opts:
              if opt in _data:
                  return float(_data[opt])
              elif opt.title() in _data:
                  return float(_data[opt.title()])
          return None
  
      def get_int_ops_scaled(_data, extra=[]):
          opts = ["inst_integer"]
          for opt in opts:
              if opt in _data:
                  value = float(_data[opt])
                  if value > 0.0:
                      return (
                          value / WARP_SIZE
                      )  # scale it by 32 because its a thread level counter
          return None
  
      def get_HBM_transactions(
          _data, extra=[]
      ):  # each transaction is 32 bytes long
          _HBM_transactions = 0
          opts = ["dram_read_transactions", "dram_write_transactions"] + extra
          for opt in opts:
              _HBM_transactions += float(_data[opt])
          if _HBM_transactions > 0.0:
              return _HBM_transactions
  
          else:
              print("No Memory Transactions counted")
              return 0
  
      def get_L2_transactions(_data, extra=[]):
          _L2_transactions = 0
          opts = ["l2_read_transactions", "l2_write_transactions"] + extra
          for opt in opts:
              _L2_transactions += float(_data[opt])
          if _L2_transactions > 0.0:
              return _L2_transactions
          else:
              return 0
  
      def get_L1_transactions(_data, extra=[]):
          _L1_transactions = 0
          opts = [
              "gld_transactions",
              "gst_transactions",
              "shared_store_transactions",
              "shared_load_transactions",
          ] + extra
          for opt in opts:
              if "shared" in opt:
                  _L1_transactions += float(_data[opt]) * 4
              else:
                  _L1_transactions += float(_data[opt])
          if _L1_transactions > 0.0:
              return _L1_transactions
          else:
              return 0
  
      def check_ignore(_ai, _op):
          if (
              "cuptiOverhead" in _ai
              or "cudaRuntime" in _ai
              or "cuptiOverhead" in _op
              or "cudaRuntime" in _op
          ):
              return True
          return False
  
      all_runtime = {}
      for i in range(0, len(ai_graph_data)):
          ai_repr = ai_graph_data[i]["entry"]["repr_data"]
          all_runtime[ai_graph_data[i]["hash"]] = get_runtime(ai_repr)
  
      for i in range(0, len(op_graph_data)):
  
          Iops = None
          HBM_transactions = None
          L1_transactions = None
          L2_transactions = None
  
          op_repr = op_graph_data[i]["entry"]["repr_data"]
  
          label = op_graph_data[i]["prefix"]
          if "thrust" in label:
              label = "thrust kernel"
          else:
              label = label.split("(")[0]
  
          if op_type == "gpu":
              Iops = get_int_ops_scaled(op_repr)
              HBM_transactions = get_HBM_transactions(op_repr)
              if HBM_transactions == 0:
                  continue
  
              L1_transactions = get_L1_transactions(op_repr)
              if L1_transactions == 0:
                  continue
              L2_transactions = get_L2_transactions(op_repr)
              if L2_transactions == 0:
                  continue
          else:
              print("no GPU data available")
  
          runtime = 0.0
          runtime = all_runtime[op_graph_data[i]["hash"]]
  
          # hotspot for HBM
          HBM_intensity = Iops / HBM_transactions  # if bandwidth != 0.0 else 0.0
          HBM_GIPS = Iops / GIGABYTE / runtime
          HBM_proportion = 0.1  # runtime / avg_runtime
  
          # hotspot for L1
          L1_intensity = Iops / L1_transactions  # if bandwidth != 0.0 else 0.0
          L1_GIPS = Iops / GIGABYTE / runtime
          L1_proportion = 0.5  # runtime / avg_runtime
  
          # hotspot for L2
          L2_intensity = Iops / L2_transactions  # if bandwidth != 0.0 else 0.0
          L2_GIPS = Iops / GIGABYTE / runtime
          L2_proportion = 1  # runtime / avg_runtime
  
          # label = re.sub(r'^[|0-9]+', ' ', label).replace("> [cxx] ", "").replace(
          #    "> [_c_] ", "").replace("> [pyc] ", "")
  
          # if VERBOSE > 1:
          #     print("intensity: {}, flop: {}, proportion: {}, label: {}".format(
          #         intensity, flop, proportion, label))
          #
          # if VERBOSE > 0:
          #     print("{} : runtime = {}, avg = {}, proportion = {}, flop = {}".format(
          #         label, runtime, avg_runtime, proportion, flop))
          #
          # # this can arise from overflow
          # if flop <= 1.0e-3 or bandwidth <= 0.0:
          #     continue
  
          my_marker = next(marker)
          hotspots.append(
              [
                  HBM_intensity,
                  HBM_GIPS,
                  HBM_proportion,
                  my_marker,
                  "HBM: " + label,
              ]
          )
          hotspots.append(
              [L1_intensity, L1_GIPS, L1_proportion, my_marker, "L1: " + label]
          )
          hotspots.append(
              [L2_intensity, L2_GIPS, L2_proportion, my_marker, "L2: " + label]
          )
      return hotspots
function_tokens: def get_hotspots_integer ( op_data , ai_data , index = None ) : import itertools marker = itertools . cycle ( ( "o" , "," , "^" , "+" , "*" , ">" , "<" ) ) if "type" not in op_data or "type" not in ai_data : return [ ] op_data_type = op_data [ "type" ] op_type = None if "cpu_roofline" in op_data_type : op_type = "cpu" if "gpu_roofline" in op_data_type : op_type = "gpu" if index is None : index = RANK_INDEX if "ranks" in op_data : op_data = op_data [ "ranks" ] [ index ] if "ranks" in ai_data : ai_data = ai_data [ "ranks" ] [ index ] op_graph_data = op_data [ "graph" ] ai_graph_data = ai_data [ "graph" ] hotspots = [ ] # avg_runtime = 1.0 # max_runtime = 0.0 # max_length = min([len(op_graph_data), len(ai_graph_data)]) all_runtime = [ ] def get_runtime ( _data , extra = [ ] ) : opts = [ "runtime" , "elapsed" ] + extra for opt in opts : if opt in _data : return float ( _data [ opt ] ) elif opt . title ( ) in _data : return float ( _data [ opt . title ( ) ] ) return None def get_int_ops_scaled ( _data , extra = [ ] ) : opts = [ "inst_integer" ] for opt in opts : if opt in _data : value = float ( _data [ opt ] ) if value > 0.0 : return ( value / WARP_SIZE ) # scale it by 32 because its a thread level counter return None def get_HBM_transactions ( _data , extra = [ ] ) : # each transaction is 32 bytes long _HBM_transactions = 0 opts = [ "dram_read_transactions" , "dram_write_transactions" ] + extra for opt in opts : _HBM_transactions += float ( _data [ opt ] ) if _HBM_transactions > 0.0 : return _HBM_transactions else : print ( "No Memory Transactions counted" ) return 0 def get_L2_transactions ( _data , extra = [ ] ) : _L2_transactions = 0 opts = [ "l2_read_transactions" , "l2_write_transactions" ] + extra for opt in opts : _L2_transactions += float ( _data [ opt ] ) if _L2_transactions > 0.0 : return _L2_transactions else : return 0 def get_L1_transactions ( _data , extra = [ ] ) : _L1_transactions = 0 opts = [ "gld_transactions" , "gst_transactions" , "shared_store_transactions" , "shared_load_transactions" , ] + extra for opt in opts : if "shared" in opt : _L1_transactions += float ( _data [ opt ] ) * 4 else : _L1_transactions += float ( _data [ opt ] ) if _L1_transactions > 0.0 : return _L1_transactions else : return 0 def check_ignore ( _ai , _op ) : if ( "cuptiOverhead" in _ai or "cudaRuntime" in _ai or "cuptiOverhead" in _op or "cudaRuntime" in _op ) : return True return False all_runtime = { } for i in range ( 0 , len ( ai_graph_data ) ) : ai_repr = ai_graph_data [ i ] [ "entry" ] [ "repr_data" ] all_runtime [ ai_graph_data [ i ] [ "hash" ] ] = get_runtime ( ai_repr ) for i in range ( 0 , len ( op_graph_data ) ) : Iops = None HBM_transactions = None L1_transactions = None L2_transactions = None op_repr = op_graph_data [ i ] [ "entry" ] [ "repr_data" ] label = op_graph_data [ i ] [ "prefix" ] if "thrust" in label : label = "thrust kernel" else : label = label . split ( "(" ) [ 0 ] if op_type == "gpu" : Iops = get_int_ops_scaled ( op_repr ) HBM_transactions = get_HBM_transactions ( op_repr ) if HBM_transactions == 0 : continue L1_transactions = get_L1_transactions ( op_repr ) if L1_transactions == 0 : continue L2_transactions = get_L2_transactions ( op_repr ) if L2_transactions == 0 : continue else : print ( "no GPU data available" ) runtime = 0.0 runtime = all_runtime [ op_graph_data [ i ] [ "hash" ] ] # hotspot for HBM HBM_intensity = Iops / HBM_transactions # if bandwidth != 0.0 else 0.0 HBM_GIPS = Iops / GIGABYTE / runtime HBM_proportion = 0.1 # runtime / avg_runtime # hotspot for L1 L1_intensity = Iops / L1_transactions # if bandwidth != 0.0 else 0.0 L1_GIPS = Iops / GIGABYTE / runtime L1_proportion = 0.5 # runtime / avg_runtime # hotspot for L2 L2_intensity = Iops / L2_transactions # if bandwidth != 0.0 else 0.0 L2_GIPS = Iops / GIGABYTE / runtime L2_proportion = 1 # runtime / avg_runtime # label = re.sub(r'^[|0-9]+', ' ', label).replace("> [cxx] ", "").replace( #    "> [_c_] ", "").replace("> [pyc] ", "") # if VERBOSE > 1: #     print("intensity: {}, flop: {}, proportion: {}, label: {}".format( #         intensity, flop, proportion, label)) # # if VERBOSE > 0: #     print("{} : runtime = {}, avg = {}, proportion = {}, flop = {}".format( #         label, runtime, avg_runtime, proportion, flop)) # # # this can arise from overflow # if flop <= 1.0e-3 or bandwidth <= 0.0: #     continue my_marker = next ( marker ) hotspots . append ( [ HBM_intensity , HBM_GIPS , HBM_proportion , my_marker , "HBM: " + label , ] ) hotspots . append ( [ L1_intensity , L1_GIPS , L1_proportion , my_marker , "L1: " + label ] ) hotspots . append ( [ L2_intensity , L2_GIPS , L2_proportion , my_marker , "L2: " + label ] ) return hotspots