mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-03 21:09:12 +00:00 
			
		
		
		
	Speed up TopoSort. The main sorting algorithm implementation in TopoSort::sort_worker is 11-12x faster. Overall, the complete sequence of building the graph and sorting is about 2.5-3x faster. The overall impact in e.g. the replace_const_cells optimization pass is a ~25% speedup. End-to-end impact on our synthesis flow is about 3%.
This commit is contained in:
		
							parent
							
								
									8fb807cd24
								
							
						
					
					
						commit
						e0042bdff7
					
				
					 5 changed files with 126 additions and 79 deletions
				
			
		| 
						 | 
				
			
			@ -424,13 +424,18 @@ void replace_const_cells(RTLIL::Design *design, RTLIL::Module *module, bool cons
 | 
			
		|||
						for (auto &bit : sig)
 | 
			
		||||
							outbit_to_cell[bit].insert(cell);
 | 
			
		||||
				}
 | 
			
		||||
			cells.node(cell);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	for (auto &it_right : cell_to_inbit)
 | 
			
		||||
	for (auto &it_sigbit : it_right.second)
 | 
			
		||||
	for (auto &it_left : outbit_to_cell[it_sigbit])
 | 
			
		||||
		cells.edge(it_left, it_right.first);
 | 
			
		||||
        // Build the graph for the topological sort.
 | 
			
		||||
	for (auto &it_right : cell_to_inbit) {
 | 
			
		||||
          const int r_index = cells.node(it_right.first);
 | 
			
		||||
          for (auto &it_sigbit : it_right.second) {
 | 
			
		||||
            for (auto &it_left : outbit_to_cell[it_sigbit]) {
 | 
			
		||||
              const int l_index = cells.node(it_left);
 | 
			
		||||
              cells.edge(l_index, r_index);
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
	cells.sort();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1032,7 +1032,7 @@ struct ShareWorker
 | 
			
		|||
		}
 | 
			
		||||
 | 
			
		||||
		bool found_scc = !toposort.sort();
 | 
			
		||||
		topo_cell_drivers = std::move(toposort.database);
 | 
			
		||||
		topo_cell_drivers = toposort.get_database();
 | 
			
		||||
 | 
			
		||||
		if (found_scc && toposort.analyze_loops)
 | 
			
		||||
			for (auto &loop : toposort.loops) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue