From a52cd4711af57f9bf8ab7b7cbecd4172b71c9b36 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Fri, 3 Sep 2010 12:14:25 +0200 Subject: [PATCH] MT operator: new separate calc start-stop lines method --- FDTD/engine_multithread.cpp | 13 ++++++++----- FDTD/operator_multithread.cpp | 31 ++++++++++++++++++++++--------- FDTD/operator_multithread.h | 8 ++++++++ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/FDTD/engine_multithread.cpp b/FDTD/engine_multithread.cpp index 44b4121..2e78bc2 100644 --- a/FDTD/engine_multithread.cpp +++ b/FDTD/engine_multithread.cpp @@ -96,6 +96,10 @@ void Engine_Multithread::Init() if (m_numThreads == 0) m_numThreads = boost::thread::hardware_concurrency(); + vector m_Start_Lines; + vector m_Stop_Lines; + m_Op_MT->CalcStartStopLines( m_numThreads, m_Start_Lines, m_Stop_Lines ); + cout << "Multithreaded engine using " << m_numThreads << " threads. Utilization: ("; m_barrier_VoltUpdate = new boost::barrier(m_numThreads); // numThread workers m_barrier_VoltExcite = new boost::barrier(m_numThreads+1); // numThread workers + 1 excitation thread @@ -110,15 +114,14 @@ void Engine_Multithread::Init() m_startBarrier = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller m_stopBarrier = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller - unsigned int linesPerThread = round((float)numLines[0] / (float)m_numThreads); for (unsigned int n=0; n &start, vector &stop) const +{ + unsigned int linesPerThread = round((float)numLines[0] / (float)numThreads); + if ((numThreads-1) * linesPerThread >= numLines[0]) + --numThreads; + + start.resize(numThreads); + stop.resize(numThreads); + + for (unsigned int n=0; n= numLines[0]) - --m_numThreads; + vector m_Start_Lines; + vector m_Stop_Lines; + CalcStartStopLines( m_numThreads, m_Start_Lines, m_Stop_Lines ); cout << "Multithreaded operator using " << m_numThreads << " threads." << std::endl; @@ -94,12 +112,7 @@ int Operator_Multithread::CalcECOperator() for (unsigned int n=0; n &start, vector &stop) const; }; class Operator_Thread