time debug code can now be disabled

This commit is contained in:
Sebastian Held 2010-03-28 13:10:16 +02:00
parent fb193ac25b
commit b8180287e9
2 changed files with 21 additions and 10 deletions

View File

@ -15,6 +15,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
//#define ENABLE_DEBUG_TIME
#ifdef ENABLE_DEBUG_TIME
#define DEBUG_TIME(x) x;
#else
#define DEBUG_TIME(x) ;
#endif
#include "engine_multithread.h" #include "engine_multithread.h"
#include "tools/array_ops.h" #include "tools/array_ops.h"
@ -38,7 +48,7 @@ Engine_Multithread::Engine_Multithread(Operator* op) : Engine(op)
Engine_Multithread::~Engine_Multithread() Engine_Multithread::~Engine_Multithread()
{ {
//DEBUG #ifdef ENABLE_DEBUG_TIME
cout << "Engine_Multithread::~Engine_Multithread()" << endl; cout << "Engine_Multithread::~Engine_Multithread()" << endl;
std::map<boost::thread::id, std::vector<double> >::iterator it; std::map<boost::thread::id, std::vector<double> >::iterator it;
for (it=m_timer_list.begin(); it!=m_timer_list.end(); it++) { for (it=m_timer_list.begin(); it!=m_timer_list.end(); it++) {
@ -52,7 +62,7 @@ Engine_Multithread::~Engine_Multithread()
std::cout << "after barrier3: " << fixed << setprecision(6) << *(it2++) << std::endl; std::cout << "after barrier3: " << fixed << setprecision(6) << *(it2++) << std::endl;
} }
} }
//DEBUG #endif
} }
@ -98,7 +108,7 @@ bool Engine_Multithread::IterateTS(unsigned int iterTS)
//cout << "... threads started"; //cout << "... threads started";
m_stopBarrier->wait(); // wait for the threads to finish <iterTS> time steps m_stopBarrier->wait(); // wait for the threads to finish <iterTS> time steps
numTS = m_numTS_times_threads; numTS = m_numTS_times_threads / m_numThreads;
return true; return true;
} }
@ -128,7 +138,7 @@ void thread::operator()()
m_enginePtr->m_startBarrier->wait(); m_enginePtr->m_startBarrier->wait();
//cout << "Thread " << boost::this_thread::get_id() << " waiting... started." << endl; //cout << "Thread " << boost::this_thread::get_id() << " waiting... started." << endl;
Timer timer1; DEBUG_TIME( Timer timer1 );
for (unsigned int iter=0;iter<m_enginePtr->m_iterTS;++iter) for (unsigned int iter=0;iter<m_enginePtr->m_iterTS;++iter)
{ {
@ -159,13 +169,13 @@ void thread::operator()()
} }
// record time // record time
m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
//cout << "Thread " << boost::this_thread::get_id() << " m_barrier1 waiting..." << endl; //cout << "Thread " << boost::this_thread::get_id() << " m_barrier1 waiting..." << endl;
m_enginePtr->m_barrier1->wait(); m_enginePtr->m_barrier1->wait();
// record time // record time
m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
// e-field excitation (thread thread_e_excitation) // e-field excitation (thread thread_e_excitation)
@ -173,7 +183,7 @@ void thread::operator()()
// e_excitation finished // e_excitation finished
// record time // record time
m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
//current updates //current updates
for (pos[0]=m_start;pos[0]<=m_stop-1;++pos[0]) for (pos[0]=m_start;pos[0]<=m_stop-1;++pos[0])
@ -199,12 +209,12 @@ void thread::operator()()
} }
// record time // record time
m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
m_enginePtr->m_barrier3->wait(); m_enginePtr->m_barrier3->wait();
// record time // record time
m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); DEBUG_TIME( m_enginePtr->m_timer_list[boost::this_thread::get_id()].push_back( timer1.elapsed() ); )
//soft current excitation here (H-field excite) //soft current excitation here (H-field excite)

View File

@ -64,8 +64,9 @@ protected:
volatile unsigned int m_numTS_times_threads; //!< numTS times the number of worker threads volatile unsigned int m_numTS_times_threads; //!< numTS times the number of worker threads
unsigned int m_numThreads; //!< number of worker threads unsigned int m_numThreads; //!< number of worker threads
//debug #ifdef ENABLE_DEBUG_TIME
std::map<boost::thread::id, std::vector<double> > m_timer_list; std::map<boost::thread::id, std::vector<double> > m_timer_list;
#endif
}; };