A few connectivity performance tweaks

This commit is contained in:
Jon Evans 2019-04-25 00:37:10 -04:00
parent 3bfe5fb84b
commit e06d37090a
2 changed files with 18 additions and 17 deletions

View File

@ -352,6 +352,7 @@ void CONNECTION_GRAPH::Reset()
m_items.clear(); m_items.clear();
m_subgraphs.clear(); m_subgraphs.clear();
m_driver_subgraphs.clear();
m_invisible_power_pins.clear(); m_invisible_power_pins.clear();
m_bus_alias_cache.clear(); m_bus_alias_cache.clear();
m_net_name_to_code_map.clear(); m_net_name_to_code_map.clear();
@ -620,7 +621,6 @@ void CONNECTION_GRAPH::buildConnectionGraph()
{ {
PROF_COUNTER phase2; PROF_COUNTER phase2;
std::vector<CONNECTION_SUBGRAPH*> driver_subgraphs;
// Recache all bus aliases for later use // Recache all bus aliases for later use
SCH_SHEET_LIST all_sheets( g_RootSheet ); SCH_SHEET_LIST all_sheets( g_RootSheet );
@ -833,7 +833,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// Now discard any non-driven subgraphs from further consideration // Now discard any non-driven subgraphs from further consideration
std::copy_if( m_subgraphs.begin(), m_subgraphs.end(), std::back_inserter( driver_subgraphs ), std::copy_if( m_subgraphs.begin(), m_subgraphs.end(), std::back_inserter( m_driver_subgraphs ),
[&] ( const CONNECTION_SUBGRAPH* candidate ) -> bool { [&] ( const CONNECTION_SUBGRAPH* candidate ) -> bool {
return candidate->m_driver; return candidate->m_driver;
} ); } );
@ -842,7 +842,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// For example, two wires that are both connected to hierarchical // For example, two wires that are both connected to hierarchical
// sheet pins that happen to have the same name, but are not the same. // sheet pins that happen to have the same name, but are not the same.
for( auto&& subgraph : driver_subgraphs ) for( auto&& subgraph : m_driver_subgraphs )
{ {
wxString full_name = subgraph->m_driver_connection->Name(); wxString full_name = subgraph->m_driver_connection->Name();
wxString name = subgraph->m_driver_connection->Name( true ); wxString name = subgraph->m_driver_connection->Name( true );
@ -933,7 +933,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
m_net_code_to_subgraphs_map[ code ].push_back( subgraph ); m_net_code_to_subgraphs_map[ code ].push_back( subgraph );
m_subgraphs.push_back( subgraph ); m_subgraphs.push_back( subgraph );
driver_subgraphs.push_back( subgraph ); m_driver_subgraphs.push_back( subgraph );
invisible_pin_subgraphs[code] = subgraph; invisible_pin_subgraphs[code] = subgraph;
} }
@ -949,8 +949,8 @@ void CONNECTION_GRAPH::buildConnectionGraph()
std::unordered_set<CONNECTION_SUBGRAPH*> invalidated_subgraphs; std::unordered_set<CONNECTION_SUBGRAPH*> invalidated_subgraphs;
for( auto subgraph_it = driver_subgraphs.begin(); for( auto subgraph_it = m_driver_subgraphs.begin();
subgraph_it != driver_subgraphs.end(); subgraph_it++ ) subgraph_it != m_driver_subgraphs.end(); subgraph_it++ )
{ {
auto subgraph = *subgraph_it; auto subgraph = *subgraph_it;
@ -1038,7 +1038,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// form neighbor links. // form neighbor links.
std::vector<CONNECTION_SUBGRAPH*> candidate_subgraphs; std::vector<CONNECTION_SUBGRAPH*> candidate_subgraphs;
std::copy_if( driver_subgraphs.begin(), driver_subgraphs.end(), std::copy_if( m_driver_subgraphs.begin(), m_driver_subgraphs.end(),
std::back_inserter( candidate_subgraphs ), std::back_inserter( candidate_subgraphs ),
[&] ( const CONNECTION_SUBGRAPH* candidate ) [&] ( const CONNECTION_SUBGRAPH* candidate )
{ return ( !candidate->m_absorbed && { return ( !candidate->m_absorbed &&
@ -1207,14 +1207,14 @@ void CONNECTION_GRAPH::buildConnectionGraph()
} }
// Absorbed subgraphs should no longer be considered // Absorbed subgraphs should no longer be considered
driver_subgraphs.erase( std::remove_if( driver_subgraphs.begin(), driver_subgraphs.end(), m_driver_subgraphs.erase( std::remove_if( m_driver_subgraphs.begin(), m_driver_subgraphs.end(),
[&] ( const CONNECTION_SUBGRAPH* candidate ) -> bool { [&] ( const CONNECTION_SUBGRAPH* candidate ) -> bool {
return candidate->m_absorbed; return candidate->m_absorbed;
} ), driver_subgraphs.end() ); } ), m_driver_subgraphs.end() );
// Store global subgraphs for later reference // Store global subgraphs for later reference
std::vector<CONNECTION_SUBGRAPH*> global_subgraphs; std::vector<CONNECTION_SUBGRAPH*> global_subgraphs;
std::copy_if( driver_subgraphs.begin(), driver_subgraphs.end(), std::copy_if( m_driver_subgraphs.begin(), m_driver_subgraphs.end(),
std::back_inserter( global_subgraphs ), std::back_inserter( global_subgraphs ),
[&] ( const CONNECTION_SUBGRAPH* candidate ) -> bool { [&] ( const CONNECTION_SUBGRAPH* candidate ) -> bool {
return !candidate->m_local_driver; return !candidate->m_local_driver;
@ -1224,7 +1224,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
// connecting bus members to their neighboring subgraphs, and then propagate connections // connecting bus members to their neighboring subgraphs, and then propagate connections
// through the hierarchy // through the hierarchy
for( auto subgraph : driver_subgraphs ) for( auto subgraph : m_driver_subgraphs )
{ {
if( !subgraph->m_dirty ) if( !subgraph->m_dirty )
continue; continue;
@ -1272,7 +1272,7 @@ void CONNECTION_GRAPH::buildConnectionGraph()
m_net_code_to_subgraphs_map.clear(); m_net_code_to_subgraphs_map.clear();
for( auto subgraph : driver_subgraphs ) for( auto subgraph : m_driver_subgraphs )
{ {
if( subgraph->m_dirty ) if( subgraph->m_dirty )
subgraph->m_dirty = false; subgraph->m_dirty = false;
@ -1347,13 +1347,12 @@ void CONNECTION_GRAPH::propagateToNeighbors( CONNECTION_SUBGRAPH* aSubgraph )
SCH_SHEET_PATH path = aParent->m_sheet; SCH_SHEET_PATH path = aParent->m_sheet;
path.push_back( sheet_pin->GetParent() ); path.push_back( sheet_pin->GetParent() );
// TODO(JE) is it worth changing this to driver_subgraphs from buildConnectionGraph? for( auto candidate : m_driver_subgraphs )
for( auto candidate : m_subgraphs )
{ {
if( candidate->m_absorbed || if( candidate->m_absorbed ||
!candidate->m_driver || !candidate->m_strong_driver ||
candidate->m_hier_ports.empty() || candidate->m_sheet != path ||
candidate->m_sheet != path ) candidate->m_hier_ports.empty() )
continue; continue;
for( SCH_HIERLABEL* label : candidate->m_hier_ports ) for( SCH_HIERLABEL* label : candidate->m_hier_ports )

View File

@ -218,6 +218,8 @@ private:
std::vector<CONNECTION_SUBGRAPH*> m_subgraphs; std::vector<CONNECTION_SUBGRAPH*> m_subgraphs;
std::vector<CONNECTION_SUBGRAPH*> m_driver_subgraphs;
std::vector<std::pair<SCH_SHEET_PATH, SCH_PIN*>> m_invisible_power_pins; std::vector<std::pair<SCH_SHEET_PATH, SCH_PIN*>> m_invisible_power_pins;
std::unordered_map< wxString, std::shared_ptr<BUS_ALIAS> > m_bus_alias_cache; std::unordered_map< wxString, std::shared_ptr<BUS_ALIAS> > m_bus_alias_cache;