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( )
|
void master( )
|
||||||
{
|
{
|
||||||
int totalWorkers = assignmentAlgo.availableWorkers();
|
int totalWorkers = assignmentAlgo.availableWorkers();
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << eo::debug;
|
eo::log << eo::debug;
|
||||||
eo::log << "[M" << comm.rank() << "] Have " << totalWorkers << " workers." << std::endl;
|
eo::log << "[M" << comm.rank() << "] Have " << totalWorkers << " workers." << std::endl;
|
||||||
|
# endif
|
||||||
|
|
||||||
while( ! isFinished() )
|
while( ! isFinished() )
|
||||||
{
|
{
|
||||||
int assignee = assignmentAlgo.get( );
|
int assignee = assignmentAlgo.get( );
|
||||||
while( assignee <= 0 )
|
while( assignee <= 0 )
|
||||||
{
|
{
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[M" << comm.rank() << "] Waitin' for node..." << std::endl;
|
eo::log << "[M" << comm.rank() << "] Waitin' for node..." << std::endl;
|
||||||
|
# endif
|
||||||
bmpi::status status = comm.probe( bmpi::any_source, bmpi::any_tag );
|
bmpi::status status = comm.probe( bmpi::any_source, bmpi::any_tag );
|
||||||
int wrkRank = status.source();
|
int wrkRank = status.source();
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[M" << comm.rank() << "] Node " << wrkRank << " just terminated." << std::endl;
|
eo::log << "[M" << comm.rank() << "] Node " << wrkRank << " just terminated." << std::endl;
|
||||||
|
# endif
|
||||||
handleResponse( wrkRank );
|
handleResponse( wrkRank );
|
||||||
assignmentAlgo.confirm( wrkRank );
|
assignmentAlgo.confirm( wrkRank );
|
||||||
assignee = assignmentAlgo.get( );
|
assignee = assignmentAlgo.get( );
|
||||||
}
|
}
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[M" << comm.rank() << "] Assignee : " << assignee << std::endl;
|
eo::log << "[M" << comm.rank() << "] Assignee : " << assignee << std::endl;
|
||||||
|
# endif
|
||||||
comm.send( assignee, Channel::Commands, Message::Continue );
|
comm.send( assignee, Channel::Commands, Message::Continue );
|
||||||
sendTask( assignee );
|
sendTask( assignee );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[M" << comm.rank() << "] Frees all the idle." << std::endl;
|
eo::log << "[M" << comm.rank() << "] Frees all the idle." << std::endl;
|
||||||
|
# endif
|
||||||
// frees all the idle workers
|
// frees all the idle workers
|
||||||
std::vector<int> idles = assignmentAlgo.idles();
|
std::vector<int> idles = assignmentAlgo.idles();
|
||||||
for(unsigned int i = 0; i < idles.size(); ++i)
|
for(unsigned int i = 0; i < idles.size(); ++i)
|
||||||
|
|
@ -75,7 +85,9 @@ namespace eo
|
||||||
comm.send( idles[i], Channel::Commands, Message::Finish );
|
comm.send( idles[i], Channel::Commands, Message::Finish );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[M" << comm.rank() << "] Waits for all responses." << std::endl;
|
eo::log << "[M" << comm.rank() << "] Waits for all responses." << std::endl;
|
||||||
|
# endif
|
||||||
// wait for all responses
|
// wait for all responses
|
||||||
while( assignmentAlgo.availableWorkers() != totalWorkers )
|
while( assignmentAlgo.availableWorkers() != totalWorkers )
|
||||||
{
|
{
|
||||||
|
|
@ -86,24 +98,34 @@ namespace eo
|
||||||
assignmentAlgo.confirm( wrkRank );
|
assignmentAlgo.confirm( wrkRank );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[M" << comm.rank() << "] Leaving master task." << std::endl;
|
eo::log << "[M" << comm.rank() << "] Leaving master task." << std::endl;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void worker( )
|
void worker( )
|
||||||
{
|
{
|
||||||
int order;
|
int order;
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << eo::debug;
|
eo::log << eo::debug;
|
||||||
|
# endif
|
||||||
while( true )
|
while( true )
|
||||||
{
|
{
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[W" << comm.rank() << "] Waiting for an order..." << std::endl;
|
eo::log << "[W" << comm.rank() << "] Waiting for an order..." << std::endl;
|
||||||
|
# endif
|
||||||
comm.recv( masterRank, Channel::Commands, order );
|
comm.recv( masterRank, Channel::Commands, order );
|
||||||
if ( order == Message::Finish )
|
if ( order == Message::Finish )
|
||||||
{
|
{
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[W" << comm.rank() << "] Leaving worker task." << std::endl;
|
eo::log << "[W" << comm.rank() << "] Leaving worker task." << std::endl;
|
||||||
|
# endif
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
# ifndef NDEBUG
|
||||||
eo::log << "[W" << comm.rank() << "] Processing task..." << std::endl;
|
eo::log << "[W" << comm.rank() << "] Processing task..." << std::endl;
|
||||||
|
# endif
|
||||||
processTask( );
|
processTask( );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue