Preprocessor conditions for debug print
This commit is contained in:
parent
b291e56e03
commit
de2df9de81
1 changed files with 22 additions and 0 deletions
|
|
@ -46,28 +46,38 @@ namespace eo
|
|||
void master( )
|
||||
{
|
||||
int totalWorkers = assignmentAlgo.availableWorkers();
|
||||
# ifndef NDEBUG
|
||||
eo::log << eo::debug;
|
||||
eo::log << "[M" << comm.rank() << "] Have " << totalWorkers << " workers." << std::endl;
|
||||
# endif
|
||||
|
||||
while( ! isFinished() )
|
||||
{
|
||||
int assignee = assignmentAlgo.get( );
|
||||
while( assignee <= 0 )
|
||||
{
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[M" << comm.rank() << "] Waitin' for node..." << std::endl;
|
||||
# endif
|
||||
bmpi::status status = comm.probe( bmpi::any_source, bmpi::any_tag );
|
||||
int wrkRank = status.source();
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[M" << comm.rank() << "] Node " << wrkRank << " just terminated." << std::endl;
|
||||
# endif
|
||||
handleResponse( wrkRank );
|
||||
assignmentAlgo.confirm( wrkRank );
|
||||
assignee = assignmentAlgo.get( );
|
||||
}
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[M" << comm.rank() << "] Assignee : " << assignee << std::endl;
|
||||
# endif
|
||||
comm.send( assignee, Channel::Commands, Message::Continue );
|
||||
sendTask( assignee );
|
||||
}
|
||||
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[M" << comm.rank() << "] Frees all the idle." << std::endl;
|
||||
# endif
|
||||
// frees all the idle workers
|
||||
std::vector<int> idles = assignmentAlgo.idles();
|
||||
for(unsigned int i = 0; i < idles.size(); ++i)
|
||||
|
|
@ -75,7 +85,9 @@ namespace eo
|
|||
comm.send( idles[i], Channel::Commands, Message::Finish );
|
||||
}
|
||||
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[M" << comm.rank() << "] Waits for all responses." << std::endl;
|
||||
# endif
|
||||
// wait for all responses
|
||||
while( assignmentAlgo.availableWorkers() != totalWorkers )
|
||||
{
|
||||
|
|
@ -86,24 +98,34 @@ namespace eo
|
|||
assignmentAlgo.confirm( wrkRank );
|
||||
}
|
||||
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[M" << comm.rank() << "] Leaving master task." << std::endl;
|
||||
# endif
|
||||
}
|
||||
|
||||
void worker( )
|
||||
{
|
||||
int order;
|
||||
# ifndef NDEBUG
|
||||
eo::log << eo::debug;
|
||||
# endif
|
||||
while( true )
|
||||
{
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[W" << comm.rank() << "] Waiting for an order..." << std::endl;
|
||||
# endif
|
||||
comm.recv( masterRank, Channel::Commands, order );
|
||||
if ( order == Message::Finish )
|
||||
{
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[W" << comm.rank() << "] Leaving worker task." << std::endl;
|
||||
# endif
|
||||
return;
|
||||
} else
|
||||
{
|
||||
# ifndef NDEBUG
|
||||
eo::log << "[W" << comm.rank() << "] Processing task..." << std::endl;
|
||||
# endif
|
||||
processTask( );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue