diff --git a/devito/logger.py b/devito/logger.py index 13a69d16239..fe751321629 100644 --- a/devito/logger.py +++ b/devito/logger.py @@ -13,13 +13,13 @@ stream_handler = logging.StreamHandler() logger.addHandler(stream_handler) -# Add extra logging levels (note: INFO has value=20, WARNING has value=30) -DEBUG = logging.DEBUG +# Add extra logging levels +DEBUG = logging.DEBUG # value=10 PERF = 19 -INFO = logging.INFO -WARNING = logging.WARNING -ERROR = logging.ERROR -CRITICAL = logging.CRITICAL +INFO = logging.INFO # value=20 +WARNING = logging.WARNING # value=30 +ERROR = logging.ERROR # value=40 +CRITICAL = logging.CRITICAL # value=50 logging.addLevelName(PERF, "PERF") @@ -71,13 +71,13 @@ def set_log_level(level, comm=None): comm : MPI communicator, optional An MPI communicator the logger should be collective over. If provided, only rank-0 on that communicator will write to the registered handlers, other - ranks will use a `logging.NullHandler`. By default, ``comm`` is set - to ``None``, so all ranks will use the default handlers. This could be + ranks will use a `logging.NullHandler`. By default, ``comm`` is set + to ``None``, so all ranks will use the default handlers. This could be used, for example, if one wants to log to one file per rank. """ from devito import configuration - if comm is not None and configuration['mpi']: + if comm is not None: if comm.rank != 0: logger.removeHandler(stream_handler) logger.addHandler(logging.NullHandler()) diff --git a/devito/operator/operator.py b/devito/operator/operator.py index 452959f4fe7..6c9a0c70bc4 100644 --- a/devito/operator/operator.py +++ b/devito/operator/operator.py @@ -872,10 +872,14 @@ def apply(self, **kwargs): # Post-process runtime arguments self._postprocess_arguments(args, **kwargs) - # Output summary of performance achieved and - # temporarily drop MPI for printing arguments - with switchconfig(mpi=False): - return self._emit_apply_profiling(args) + # In case MPI is used restrict result logging to one rank only + if configuration['mpi']: + # Only temporarily change configuration + with switchconfig(mpi=True): + set_log_level('DEBUG', comm=args.comm) + return self._emit_apply_profiling(args) + + return self._emit_apply_profiling(args) # Performance profiling @@ -913,9 +917,6 @@ def _emit_timings(timings, indent=''): def _emit_apply_profiling(self, args): """Produce a performance summary of the profiled sections.""" - # In case MPI is used restrict result logging to one rank - set_log_level('DEBUG', comm=args.comm) - # Rounder to 2 decimal places fround = lambda i: ceil(i * 100) / 100