original_docstring:  Attempt to merge instructions of type instruction_type (which are given in
          merge_nodes) using longest paths algorithm.
  
          Returns the no. of rounds of communication required after merging (assuming 1 round/instruction).
  
          Doesn't use networkx.
          
docstring: Attempt to merge instructions of type instruction_type (which are given in
  merge_nodes) using longest paths algorithm.
  
  Returns the no. of rounds of communication required after merging (assuming 1 round/instruction).
  
  Doesn't use networkx.
docstring_tokens: Attempt to merge instructions of type instruction_type ( which are given in merge_nodes ) using longest paths algorithm . Returns the no . of rounds of communication required after merging ( assuming 1 round / instruction ) . Doesn ' t use networkx .
code: def longest_paths_merge(self):
          """ Attempt to merge instructions of type instruction_type (which are given in
          merge_nodes) using longest paths algorithm.
  
          Returns the no. of rounds of communication required after merging (assuming 1 round/instruction).
  
          Doesn't use networkx.
          """
          G = self.G
          instructions = self.instructions
          merge_nodes = self.open_nodes
          depths = self.depths
          if not merge_nodes:
              return 0
  
          # merge opens at same depth
          merges = defaultdict(list)
          for node in merge_nodes:
              merges[depths[node]].append(node)
  
          # after merging, the first element in merges[i] remains for each depth i,
          # all others are removed from instructions and G
          last_nodes = [None, None]
          for i in sorted(merges):
              merge = merges[i]
              t = type(self.instructions[merge[0]])
              self.counter[t] += len(merge)
              self.rounds[t] += 1
              if len(merge) > 10000:
                  print('Merging %d %s in round %d/%d' % \
                      (len(merge), t.__name__, i, len(merges)))
              self.do_merge(merge)
  
          preorder = None
  
          if len(instructions) > 1000000:
              print("Topological sort ...")
          order = Compiler.graph.topological_sort(G, preorder)
          instructions[:] = [instructions[i] for i in order if instructions[i] is not None]
          if len(instructions) > 1000000:
              print("Done at", time.asctime())
  
          return len(merges)
code_tokens: def longest_paths_merge ( self ) : G = self . G instructions = self . instructions merge_nodes = self . open_nodes depths = self . depths if not merge_nodes : return 0 merges = defaultdict ( list ) for node in merge_nodes : merges [ depths [ node ] ] . append ( node ) last_nodes = [ None , None ] for i in sorted ( merges ) : merge = merges [ i ] t = type ( self . instructions [ merge [ 0 ] ] ) self . counter [ t ] += len ( merge ) self . rounds [ t ] += 1 if len ( merge ) > 10000 : print ( 'Merging %d %s in round %d/%d' % ( len ( merge ) , t . __name__ , i , len ( merges ) ) ) self . do_merge ( merge ) preorder = None if len ( instructions ) > 1000000 : print ( "Topological sort ..." ) order = Compiler . graph . topological_sort ( G , preorder ) instructions [ : ] = [ instructions [ i ] for i in order if instructions [ i ] is not None ] if len ( instructions ) > 1000000 : print ( "Done at" , time . asctime ( ) ) return len ( merges )
short_docstring: Attempt to merge instructions of type instruction_type (which are given in
  merge_nodes) using longest paths algorithm.
short_docstring_tokens: Attempt to merge instructions of type instruction_type ( which are given in merge_nodes ) using longest paths algorithm .
comment: """ Attempt to merge instructions of type instruction_type (which are given in
          merge_nodes) using longest paths algorithm.
  
          Returns the no. of rounds of communication required after merging (assuming 1 round/instruction).
  
          Doesn't use networkx.
          """$SEP$# merge opens at same depth
  $SEP$# after merging, the first element in merges[i] remains for each depth i,
  $SEP$# all others are removed from instructions and G
  