Parallelized the RN_DATA::Recalculate() function.

This commit is contained in:
Carl Poirier 2014-01-31 18:27:06 +01:00 committed by Maciej Suminski
parent a10d918cac
commit 1490099ddd
3 changed files with 32 additions and 5 deletions

View File

@ -125,6 +125,13 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" )
endif()
find_package( OpenMP QUIET )
if( OPENMP_FOUND )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
add_definitions( -DUSE_OPENMP )
endif()
if( MINGW )
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )

View File

@ -1,6 +1,8 @@
set( MAKE_LINK_MAPS false )
set( CMAKE_CXX_FLAGS "-fopenmp" )
add_definitions( -DPCBNEW )
add_subdirectory(router)

View File

@ -27,6 +27,10 @@
* @brief Class that computes missing connections on a PCB.
*/
#ifdef USE_OPENMP
#include <omp.h>
#endif /* USE_OPENMP */
#include <ratsnest_data.h>
#include <class_board.h>
@ -829,12 +833,25 @@ void RN_DATA::Recalculate( int aNet )
{
if( aNet < 0 ) // Recompute everything
{
// Start with net number 1, as 0 stand for not connected
for( unsigned int i = 1; i < m_board->GetNetCount(); ++i )
unsigned int tid, i, chunk, netCount;
netCount = m_board->GetNetCount();
chunk = 1;
#ifdef USE_OPENMP
#pragma omp parallel shared(chunk, netCount) private(i, tid)
{
if( m_nets[i].IsDirty() )
updateNet( i );
}
tid = omp_get_thread_num();
#pragma omp for schedule(guided, chunk)
#else /* USE_OPENMP */
{
#endif
// Start with net number 1, as 0 stand for not connected
for( i = 1; i < netCount; ++i )
{
if( m_nets[i].IsDirty() )
updateNet( i );
}
} /* end of parallel section */
}
else if( aNet > 0 ) // Recompute only specific net
{
@ -848,3 +865,4 @@ void RN_DATA::ClearSimple()
BOOST_FOREACH( RN_NET& net, m_nets )
net.ClearSimple();
}