For anyone looking to remove all duplicated console output when running Catch2 distributed, here's a solution.
Find the definition of ConsoleReporter
in catch.hpp
(in v2.10.0, it's at line 15896). It will look something like:
ConsoleReporter::ConsoleReporter(ReporterConfig const& config)
: StreamingReporterBase(config),
m_tablePrinter(new TablePrinter(config.stream(),
[&config]() -> std::vector<ColumnInfo> {
if (config.fullConfig()->benchmarkNoAnalysis())
{
return{
{ "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left },
{ " samples", 14, ColumnInfo::Right },
{ " iterations", 14, ColumnInfo::Right },
{ " mean", 14, ColumnInfo::Right }
};
}
else
{
return{
{ "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left },
{ "samples mean std dev", 14, ColumnInfo::Right },
{ "iterations low mean low std dev", 14, ColumnInfo::Right },
{ "estimated high mean high std dev", 14, ColumnInfo::Right }
};
}
}())) {}
ConsoleReporter::~ConsoleReporter() = default;
Though not shown here, the base-class StreamingReporterBase
provides a stream
attribute which we'll disable, by the failbit
trick shown here.
Inside the final {}
above (an empty constructor definition), insert:
// I solemnly swear that I am up to no good
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// silence non-root nodes
if (rank != 0)
stream.setstate(std::ios_base::failbit);
You can see an example on this repo.