From cf04d341ec3583ee8fe04773e3eea7f91be110cb Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 20 Jun 2018 23:20:01 -0700 Subject: [PATCH] pcbnew: standardize itemlist/zonelist connectivity The itemlist and zonelist in connectivity can both contain many items, so both use the same OpenMP routine. However, we can only clear the dirty flag when we conduct a full search, including zones. Otherwise we missing connections to zones when propogating changed items that are then marked as not dirty. Fixes: lp:1777993 * https://bugs.launchpad.net/kicad/+bug/1777993 --- pcbnew/connectivity_algo.cpp | 43 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/pcbnew/connectivity_algo.cpp b/pcbnew/connectivity_algo.cpp index 9d110ddbfc..3a86d0ec5d 100644 --- a/pcbnew/connectivity_algo.cpp +++ b/pcbnew/connectivity_algo.cpp @@ -345,8 +345,12 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) if( m_itemList.IsDirty() ) { - for( auto item : m_itemList ) + #ifdef USE_OPENMP + #pragma omp parallel for schedule(dynamic) + #endif + for( int i = 0; i < m_itemList.Size(); i++ ) { + auto item = m_itemList[i]; if( item->Dirty() ) { CN_VISITOR visitor( item, &cnListLock ); @@ -370,44 +374,25 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) } #ifdef USE_OPENMP - // launch at least two threads, one to compute, second to update UI - #pragma omp parallel num_threads( std::max( omp_get_num_procs(), 2 ) ) + #pragma omp parallel for schedule(dynamic) #endif + for(int i = 0; i < m_zoneList.Size(); i++ ) { - #ifdef USE_OPENMP - #pragma omp master - if (m_progressReporter) - { - m_progressReporter->KeepRefreshing( true ); - } - #endif + auto item = m_zoneList[i]; + auto zoneItem = static_cast (item); - #ifdef USE_OPENMP - #pragma omp for schedule(dynamic) - #endif - for(int i = 0; i < m_zoneList.Size(); i++ ) + if( zoneItem->Dirty() ) { - auto item = m_zoneList[i]; - auto zoneItem = static_cast (item); - - if( zoneItem->Dirty() ) - { - CN_VISITOR visitor( item, &cnListLock ); - m_itemList.FindNearby( item, visitor ); - m_zoneList.FindNearby( item, visitor ); - } - - if (m_progressReporter) - { - m_progressReporter->AdvanceProgress(); - } + CN_VISITOR visitor( item, &cnListLock ); + m_itemList.FindNearby( item, visitor ); + m_zoneList.FindNearby( item, visitor ); } } m_zoneList.ClearDirtyFlags(); + m_itemList.ClearDirtyFlags(); } - m_itemList.ClearDirtyFlags(); #ifdef CONNECTIVITY_DEBUG printf("Search end\n");