Logger::log not only output on root process
calling
Logger::log(msg,lv)
is delegated to
Logger::write(lv,msg,-1)
, where -1 is then used as rank of the process in Logger::write.
In this situation the following code fragment from Logger::write
const bool std_out_all_processes = parameters["std_out_all_processes"];
if (rank > 0 && !std_out_all_processes && log_level < WARNING)
return;
will never return and in a consequence the later logging will be performed on all processes independent of the parameter std_out_all_processes
Edit: I circumvented this by setting
Logger::set_log_active(false);
on all non root processes.
Best regards
Christian
Comments (8)
-
-
reporter - edited description
-
reporter Thanks for the answer. Using MPI::rank(MPI_COMM_WORLD) instead of '-1' will fix this problem.
Anyway the setting of '-1' seems originally be done to indicate that we run serial code and that the output does not need a prefix from which process it stems. Direct after
const bool std_out_all_processes = parameters["std_out_all_processes"]; if (rank > 0 && !std_out_all_processes && log_level < WARNING) return;
The code proceeds:
// Prefix with process number if running in parallel if (rank >= 0) { std::stringstream prefix; prefix << "Process " << rank << ": "; msg = prefix.str() + msg; }
I am sorry for not mentioning this point before. So using MPI::rank(MPI_COMM_WORLD); will always use the prefix. I think one way to circumvent this would be adding the following code at the very beginning of Logger::write(lv,msg,rank)
if (MPI::size(MPI_COMM_WORLD)==1) rank = -1;
additionaly to using
MPI::rank(MPI_COMM_WORLD)
in Logger::log(msg,lv)
Best regards,
Christian
-
Well, better to say
if (MPI::size(MPI_COMM_WORLD) > 1)
instead ofif (rank >= 0)
. Anyway, a little more clean-up required. This should make 1.6 release. -
-
assigned issue to
-
assigned issue to
-
- changed milestone to 1.6
-
- changed status to resolved
Logger now has mpi_comm in master
-
- removed milestone
Removing milestone: 1.6 (automated comment)
- Log in to comment
This should be an easy fix, just replace
-1
withMPI::rank(MPI_COMM_WORLD)