Commit b38cf6ec authored by Andrew Bauer's avatar Andrew Bauer

Adding in optional value to reduce the amount of processes outputting log info.

parent 4ca5aaf7
Pipeline #11185 skipped
......@@ -272,7 +272,7 @@ void MarkEndTimeStep()
}
//-----------------------------------------------------------------------------
void PrintLog(std::ostream& stream, MPI_Comm world)
void PrintLog(std::ostream& stream, MPI_Comm world, int moduloOutput)
{
if (!impl::LoggingEnabled)
{
......@@ -283,6 +283,11 @@ void PrintLog(std::ostream& stream, MPI_Comm world)
MPI_Comm_size(world, &nprocs);
MPI_Comm_rank(world, &rank);
if(moduloOutput < 1)
{
moduloOutput = 1;
}
std::ostringstream tmp;
std::ostream &output = (rank == 0)? stream : tmp;
......@@ -293,7 +298,10 @@ void PrintLog(std::ostream& stream, MPI_Comm world)
<< " Time/Memory log (rank: 0) \n"
<< " -------------------------------------------------------------\n";
}
impl::PrintLog(output, impl::Indent());
if(rank % moduloOutput == 0)
{
impl::PrintLog(output, impl::Indent());
}
if(rank == 0)
{
output << "=================================================================\n";
......@@ -321,12 +329,15 @@ void PrintLog(std::ostream& stream, MPI_Comm world)
for (int cc=1; cc < nprocs; cc++)
{
output << "\n"
<< "=================================================================\n"
<< " Time/Memory log (rank: " << cc << ") \n"
<< " -------------------------------------------------------------\n";
output << (recv_buffer + recv_offsets[cc]);
output << "=================================================================\n";
if(cc % moduloOutput == 0)
{
output << "\n"
<< "=================================================================\n"
<< " Time/Memory log (rank: " << cc << ") \n"
<< " -------------------------------------------------------------\n";
output << (recv_buffer + recv_offsets[cc]);
output << "=================================================================\n";
}
}
delete []recv_buffer;
......
......@@ -54,8 +54,10 @@ namespace timer
/// @brief Print log to the output stream.
///
/// Note this triggers collective operations and hence must be called on all
/// ranks.
void PrintLog(std::ostream& stream, MPI_Comm world);
/// ranks. The amount of processes outputting can be reduced by using
/// the moduloOuput which only outputs for (rank % moduloOutput) == 0.
/// The default value for this is 1.
void PrintLog(std::ostream& stream, MPI_Comm world, int moduloOutput = 1);
class MarkEvent
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment