From 91ecb547d6d3b8df121c1194842a9238be3d6010 Mon Sep 17 00:00:00 2001 From: Thorsten Liebig Date: Tue, 29 Jun 2010 12:44:47 +0200 Subject: [PATCH] fix in multithreading linesPerThread Signed-off-by: Thorsten Liebig --- FDTD/engine_multithread.cpp | 13 ++++++++++--- FDTD/engine_sse_compressed.cpp | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/FDTD/engine_multithread.cpp b/FDTD/engine_multithread.cpp index 99ce1de..9c70e83 100644 --- a/FDTD/engine_multithread.cpp +++ b/FDTD/engine_multithread.cpp @@ -94,7 +94,12 @@ void Engine_Multithread::Init() m_stopThreads = false; if (m_numThreads == 0) m_numThreads = boost::thread::hardware_concurrency(); - cout << "Multithreaded engine using " << m_numThreads << " threads." << std::endl; + + unsigned int linesPerThread = round((float)numLines[0] / (float)m_numThreads); + if ((m_numThreads-1) * linesPerThread >= numLines[0]) + --m_numThreads; + + 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 m_barrier_CurrUpdate = new boost::barrier(m_numThreads); // numThread workers @@ -108,7 +113,6 @@ 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