diff --git a/FDTD/engine_multithread.cpp b/FDTD/engine_multithread.cpp index 0007955..1179b38 100644 --- a/FDTD/engine_multithread.cpp +++ b/FDTD/engine_multithread.cpp @@ -44,7 +44,7 @@ Engine_Multithread* Engine_Multithread::New(const Operator_Multithread* op, unsi return e; } -Engine_Multithread::Engine_Multithread(const Operator_Multithread* op) : Engine_SSE_Compressed(op) +Engine_Multithread::Engine_Multithread(const Operator_Multithread* op) : ENGINE_MULTITHREAD_BASE(op) { m_Op_MT = op; m_type = SSE; @@ -84,7 +84,7 @@ void Engine_Multithread::setNumThreads( unsigned int numThreads ) void Engine_Multithread::Init() { m_stopThreads = true; - Engine_SSE_Compressed::Init(); + ENGINE_MULTITHREAD_BASE::Init(); // initialize threads m_stopThreads = false; @@ -144,7 +144,7 @@ void Engine_Multithread::Reset() m_stopBarrier = 0; } - Engine_SSE_Compressed::Reset(); + ENGINE_MULTITHREAD_BASE::Reset(); } bool Engine_Multithread::IterateTS(unsigned int iterTS) @@ -241,7 +241,6 @@ void thread::operator()() //std::cout << "thread::operator() Parameters: " << m_start << " " << m_stop << std::endl; //DBG().cout() << "Thread " << m_threadID << " (" << boost::this_thread::get_id() << ") started." << endl; - while (!m_enginePtr->m_stopThreads) { // wait for start @@ -278,6 +277,12 @@ void thread::operator()() m_enginePtr->m_IterateBarrier->wait(); // voltage excitation finished +#ifdef MPI_SUPPORT + if (m_threadID==0) + m_enginePtr->SendReceiveVoltages(); + m_enginePtr->m_IterateBarrier->wait(); +#endif + // record time DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); ) @@ -305,6 +310,12 @@ void thread::operator()() m_enginePtr->m_IterateBarrier->wait(); // current excitation finished +#ifdef MPI_SUPPORT + if (m_threadID==0) + m_enginePtr->SendReceiveCurrents(); + m_enginePtr->m_IterateBarrier->wait(); +#endif + if (m_threadID == 0) ++m_enginePtr->numTS; // only the first thread increments numTS } diff --git a/FDTD/engine_multithread.h b/FDTD/engine_multithread.h index 9e72159..536c0f7 100644 --- a/FDTD/engine_multithread.h +++ b/FDTD/engine_multithread.h @@ -32,6 +32,14 @@ #include +#ifdef MPI_SUPPORT + #define ENGINE_MULTITHREAD_BASE Engine_MPI + #include "engine_mpi.h" +#else + #define ENGINE_MULTITHREAD_BASE Engine_SSE_Compressed +#endif + + class Engine_Multithread; namespace NS_Engine_Multithread @@ -69,7 +77,7 @@ protected: } // namespace -class Engine_Multithread : public Engine_SSE_Compressed +class Engine_Multithread : public ENGINE_MULTITHREAD_BASE { friend class NS_Engine_Multithread::thread; friend class Engine_CylinderMultiGrid; diff --git a/FDTD/operator_multithread.cpp b/FDTD/operator_multithread.cpp index 77c536e..11f7d7a 100644 --- a/FDTD/operator_multithread.cpp +++ b/FDTD/operator_multithread.cpp @@ -44,7 +44,7 @@ Engine* Operator_Multithread::CreateEngine() const return e; } -Operator_Multithread::Operator_Multithread() : Operator_SSE_Compressed() +Operator_Multithread::Operator_Multithread() : OPERATOR_MULTITHREAD_BASE() { m_CalcEC_Start=NULL; m_CalcEC_Stop=NULL; @@ -55,7 +55,7 @@ Operator_Multithread::Operator_Multithread() : Operator_SSE_Compressed() void Operator_Multithread::Init() { - Operator_SSE_Compressed::Init(); + OPERATOR_MULTITHREAD_BASE::Init(); m_CalcEC_Start=NULL; m_CalcEC_Stop=NULL; @@ -82,7 +82,7 @@ void Operator_Multithread::Delete() void Operator_Multithread::Reset() { Delete(); - Operator_SSE_Compressed::Reset(); + OPERATOR_MULTITHREAD_BASE::Reset(); } void Operator_Multithread::CalcStartStopLines(unsigned int &numThreads, vector &start, vector &stop) const @@ -132,7 +132,7 @@ int Operator_Multithread::CalcECOperator( DebugFlags debugFlags ) m_thread_group.add_thread( t ); } - return Operator_SSE_Compressed::CalcECOperator( debugFlags ); + return OPERATOR_MULTITHREAD_BASE::CalcECOperator( debugFlags ); } bool Operator_Multithread::Calc_EC() diff --git a/FDTD/operator_multithread.h b/FDTD/operator_multithread.h index fcb6f83..eefe188 100644 --- a/FDTD/operator_multithread.h +++ b/FDTD/operator_multithread.h @@ -22,7 +22,14 @@ #include -class Operator_Multithread : public Operator_SSE_Compressed +#ifdef MPI_SUPPORT + #define OPERATOR_MULTITHREAD_BASE Operator_MPI + #include "operator_mpi.h" +#else + #define OPERATOR_MULTITHREAD_BASE Operator_SSE_Compressed +#endif + +class Operator_Multithread : public OPERATOR_MULTITHREAD_BASE { friend class Engine_Multithread; friend class Operator_Thread;