fix in multithreading linesPerThread

Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
pull/1/head
Thorsten Liebig 2010-06-29 12:44:47 +02:00
parent 0f4a78cdbf
commit 91ecb547d6
2 changed files with 11 additions and 4 deletions

View File

@ -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<m_numThreads; n++) {
unsigned int start = n * linesPerThread;
unsigned int stop = (n+1) * linesPerThread - 1;
@ -117,7 +121,10 @@ void Engine_Multithread::Init()
// last thread
stop = numLines[0]-1;
stop_h = stop-1;
cout << stop-start+1 << ")" << endl;
}
else
cout << stop-start+1 << ";";
// NS_Engine_Multithread::DBG().cout() << "###DEBUG## Thread " << n << ": start=" << start << " stop=" << stop << " stop_h=" << stop_h << std::endl;
boost::thread *t = new boost::thread( NS_Engine_Multithread::thread(this,start,stop,stop_h,n) );
m_thread_group.add_thread( t );

View File

@ -93,7 +93,7 @@ void Engine_SSE_Compressed::UpdateVoltages(unsigned int startX, unsigned int num
void Engine_SSE_Compressed::UpdateCurrents(unsigned int startX, unsigned int numX)
{
unsigned int pos[5];
unsigned int pos[3];
f4vector temp;
pos[0] = startX;