From 86566fc14293fca4f8adeb6c094496d81ea3412c Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 9 Feb 2018 14:14:32 +0100 Subject: [PATCH] Fix a hang-up during zone filling On OpenMP single core systems only the first thread launched. It means that only the UI updating thread was running, without the one responsible for actual computation. It is fixed by enforcing at least two threads. --- pcbnew/connectivity_algo.cpp | 7 ++++++- pcbnew/zone_filler.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pcbnew/connectivity_algo.cpp b/pcbnew/connectivity_algo.cpp index acac2d55e2..52384923b8 100644 --- a/pcbnew/connectivity_algo.cpp +++ b/pcbnew/connectivity_algo.cpp @@ -32,6 +32,10 @@ #include #endif +#ifdef USE_OPENMP +#include +#endif /* USE_OPENMP */ + using namespace std::placeholders; bool operator<( const CN_ANCHOR_PTR& a, const CN_ANCHOR_PTR& b ) @@ -521,7 +525,8 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) } #ifdef USE_OPENMP - #pragma omp parallel + // launch at least two threads, one to compute, second to update UI + #pragma omp parallel num_threads( std::max( omp_get_num_procs(), 2 ) ) #endif { #ifdef USE_OPENMP diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 327df69de6..7797e4a81d 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -116,7 +116,8 @@ void ZONE_FILLER::Fill( std::vector aZones ) #ifdef USE_OPENMP - #pragma omp parallel + // launch at least two threads, one to compute, second to update UI + #pragma omp parallel num_threads( std::max( omp_get_num_procs(), 2 ) ) #endif { #ifdef USE_OPENMP @@ -177,7 +178,8 @@ void ZONE_FILLER::Fill( std::vector aZones ) m_progressReporter->SetMaxProgress( toFill.size() ); } #ifdef USE_OPENMP - #pragma omp parallel + // launch at least two threads, one to compute, second to update UI + #pragma omp parallel num_threads( std::max( omp_get_num_procs(), 2 ) ) #endif { #ifdef USE_OPENMP