operator: multithreaded CalcPEC
This commit is contained in:
parent
e816d50cc1
commit
08fd499194
@ -1064,14 +1064,14 @@ bool Operator::CalcPEC()
|
||||
{
|
||||
m_Nr_PEC[0]=0; m_Nr_PEC[1]=0; m_Nr_PEC[2]=0;
|
||||
|
||||
CalcPEC_Range(0,numLines[0]-1);
|
||||
CalcPEC_Range(0,numLines[0]-1,m_Nr_PEC);
|
||||
|
||||
CalcPEC_Curves();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX)
|
||||
void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX, unsigned int* counter)
|
||||
{
|
||||
double coord[3];
|
||||
double delta;
|
||||
@ -1087,7 +1087,6 @@ void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX)
|
||||
coord[0] = discLines[0][pos[0]];
|
||||
coord[1] = discLines[1][pos[1]];
|
||||
coord[2] = discLines[2][pos[2]];
|
||||
MainOp->SetPos(pos[0],pos[1],pos[2]);
|
||||
delta=MainOp->GetIndexDelta(n,pos[n]);
|
||||
coord[n]= discLines[n][pos[n]] + delta*0.5;
|
||||
CSProperties* prop = CSX->GetPropertyByCoordPriority(coord, (CSProperties::PropertyType)(CSProperties::MATERIAL | CSProperties::METAL));
|
||||
@ -1097,7 +1096,7 @@ void Operator::CalcPEC_Range(unsigned int startX, unsigned int stopX)
|
||||
{
|
||||
GetVV(n,pos[0],pos[1],pos[2]) = 0;
|
||||
GetVI(n,pos[0],pos[1],pos[2]) = 0;
|
||||
++m_Nr_PEC[n];
|
||||
++counter[n];
|
||||
// cerr << "CartOperator::CalcPEC: PEC found at " << pos[0] << " ; " << pos[1] << " ; " << pos[2] << endl;
|
||||
}
|
||||
}
|
||||
|
@ -106,8 +106,9 @@ protected:
|
||||
//! Calculate the field excitations.
|
||||
virtual bool CalcFieldExcitation();
|
||||
|
||||
unsigned int m_Nr_PEC[3]; //count PEC edges
|
||||
virtual bool CalcPEC();
|
||||
virtual void CalcPEC_Range(unsigned int startX, unsigned int stopX); //internal to CalcPEC
|
||||
virtual void CalcPEC_Range(unsigned int startX, unsigned int stopX, unsigned int* counter); //internal to CalcPEC
|
||||
virtual void CalcPEC_Curves(); //internal to CalcPEC
|
||||
|
||||
//Calc timestep only internal use
|
||||
@ -127,8 +128,6 @@ protected:
|
||||
double* EC_L[3];
|
||||
double* EC_R[3];
|
||||
|
||||
unsigned int m_Nr_PEC[3];
|
||||
|
||||
int m_MeshType;
|
||||
unsigned int numLines[3];
|
||||
double* discLines[3];
|
||||
|
@ -46,6 +46,9 @@ Operator_Multithread::Operator_Multithread()
|
||||
{
|
||||
m_CalcEC_Start=NULL;
|
||||
m_CalcEC_Stop=NULL;
|
||||
|
||||
m_CalcPEC_Start=NULL;
|
||||
m_CalcPEC_Stop=NULL;
|
||||
}
|
||||
|
||||
void Operator_Multithread::Init()
|
||||
@ -53,6 +56,9 @@ void Operator_Multithread::Init()
|
||||
Operator_SSE_Compressed::Init();
|
||||
m_CalcEC_Start=NULL;
|
||||
m_CalcEC_Stop=NULL;
|
||||
|
||||
m_CalcPEC_Start=NULL;
|
||||
m_CalcPEC_Stop=NULL;
|
||||
}
|
||||
|
||||
void Operator_Multithread::Reset()
|
||||
@ -63,6 +69,9 @@ void Operator_Multithread::Reset()
|
||||
|
||||
delete m_CalcEC_Start;m_CalcEC_Start=NULL;
|
||||
delete m_CalcEC_Stop;m_CalcEC_Stop=NULL;
|
||||
|
||||
delete m_CalcPEC_Start;m_CalcPEC_Start=NULL;
|
||||
delete m_CalcPEC_Stop;m_CalcPEC_Stop=NULL;
|
||||
}
|
||||
|
||||
int Operator_Multithread::CalcECOperator()
|
||||
@ -76,6 +85,9 @@ int Operator_Multithread::CalcECOperator()
|
||||
delete m_CalcEC_Start;m_CalcEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller
|
||||
delete m_CalcEC_Stop;m_CalcEC_Stop = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller
|
||||
|
||||
delete m_CalcPEC_Start;m_CalcPEC_Start = new boost::barrier(m_numThreads+1); // numThread workers + 1 controller
|
||||
delete m_CalcPEC_Stop;m_CalcPEC_Stop = 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++)
|
||||
{
|
||||
@ -104,6 +116,28 @@ bool Operator_Multithread::Calc_EC()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Operator_Multithread::CalcPEC()
|
||||
{
|
||||
m_Nr_PEC[0]=0; m_Nr_PEC[1]=0; m_Nr_PEC[2]=0;
|
||||
|
||||
m_Nr_PEC_thread = new unsigned int[m_numThreads][3];
|
||||
|
||||
m_CalcPEC_Start->wait();
|
||||
|
||||
m_CalcPEC_Stop->wait();
|
||||
|
||||
for (unsigned int t=0;t<m_numThreads;++t)
|
||||
for (int n=0;n<3;++n)
|
||||
m_Nr_PEC[n]+=m_Nr_PEC_thread[t][n];
|
||||
|
||||
CalcPEC_Curves();
|
||||
|
||||
delete[] m_Nr_PEC_thread;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Operator_Thread::Operator_Thread( Operator_Multithread* ptr, unsigned int start, unsigned int stop, unsigned int threadID )
|
||||
{
|
||||
m_start=start;
|
||||
@ -138,5 +172,13 @@ void Operator_Thread::operator()()
|
||||
}
|
||||
}
|
||||
m_OpPtr->m_CalcEC_Stop->wait();
|
||||
|
||||
//************** calculate EC (Calc_EC) ***********************//
|
||||
m_OpPtr->m_CalcPEC_Start->wait();
|
||||
for (int n=0;n<3;++n)
|
||||
m_OpPtr->m_Nr_PEC_thread[m_threadID][n] = 0;
|
||||
|
||||
m_OpPtr->CalcPEC_Range(m_start,m_stop,m_OpPtr->m_Nr_PEC_thread[m_threadID]);
|
||||
m_OpPtr->m_CalcPEC_Stop->wait();
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,16 @@ protected:
|
||||
|
||||
virtual bool Calc_EC(); //this method is using multi-threading
|
||||
|
||||
unsigned int (*m_Nr_PEC_thread)[3]; //count PEC edges per thread
|
||||
virtual bool CalcPEC(); //this method is using multi-threading
|
||||
|
||||
//Calc_EC barrier
|
||||
boost::barrier* m_CalcEC_Start;
|
||||
boost::barrier* m_CalcEC_Stop;
|
||||
//CalcPEC barrier
|
||||
boost::barrier* m_CalcPEC_Start;
|
||||
boost::barrier* m_CalcPEC_Stop;
|
||||
|
||||
boost::thread_group m_thread_group;
|
||||
unsigned int m_numThreads; // number of worker threads
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user