Fix single-threaded loads/connectivity

We cannot set thread counts to hardware_concurrency()-1 without
considering that single core machines will get a thread count of 0.
This commit is contained in:
Seth Hillbrand 2021-12-14 17:17:43 -08:00
parent 965ab42938
commit 40d44c94cd
4 changed files with 7 additions and 6 deletions

View File

@ -39,7 +39,7 @@ SYMBOL_ASYNC_LOADER::SYMBOL_ASYNC_LOADER( const std::vector<wxString>& aNickname
m_canceled( false )
{
wxASSERT( m_table );
m_threadCount = std::max<size_t>( 1, std::thread::hardware_concurrency() - 1 );
m_threadCount = std::max<size_t>( 1, std::thread::hardware_concurrency() );
m_returns.resize( m_threadCount );
}

View File

@ -143,7 +143,7 @@ void CONNECTIVITY_DATA::updateRatsnest()
} );
// We don't want to spin up a new thread for fewer than 8 nets (overhead costs)
size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency() - 1,
size_t parallelThreadCount = std::min<size_t>( std::thread::hardware_concurrency(),
( dirty_nets.size() + 7 ) / 8 );
std::atomic<size_t> nextNet( 0 );
@ -158,7 +158,7 @@ void CONNECTIVITY_DATA::updateRatsnest()
return 1;
};
if( parallelThreadCount == 1 )
if( parallelThreadCount <= 1 )
{
update_lambda();
}

View File

@ -79,6 +79,8 @@ bool DRC_TEST_PROVIDER_CONNECTIVITY::Run()
std::shared_ptr<CONNECTIVITY_DATA> connectivity = board->GetConnectivity();
std::lock_guard<KISPINLOCK> lock( connectivity->GetLock() );
// Rebuild just in case. This really needs to be reliable.
connectivity->Clear();
connectivity->Build( board, m_drcEngine->GetProgressReporter() );
@ -149,7 +151,6 @@ bool DRC_TEST_PROVIDER_CONNECTIVITY::Run()
if( !reportPhase( _( "Checking net connections..." ) ) )
return false; // DRC cancelled
connectivity->RecalculateRatsnest();
std::vector<CN_EDGE> edges;
connectivity->GetUnconnectedEdges( edges );

View File

@ -185,7 +185,7 @@ void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard, PROGRESS_REPORTER* aReport
auto zones = aBoard->Zones();
std::atomic<size_t> next( 0 );
std::atomic<size_t> count_done( 0 );
size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency() - 1, 2 );
size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
for( size_t ii = 0; ii < parallelThreadCount; ++ii )
{