From 00a4c3424a860953174eef842e23eb8c8fab5379 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Tue, 5 Dec 2023 18:59:27 +0000 Subject: [PATCH] docs: Use with --- FAQ.md | 2 +- devito/logger.py | 2 +- devito/operator/operator.py | 24 ++++++++---------------- devito/operator/profiling.py | 2 +- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/FAQ.md b/FAQ.md index 9ed60189de4..ecd011faea7 100644 --- a/FAQ.md +++ b/FAQ.md @@ -23,7 +23,7 @@ - [Can I subclass basic types such as TimeFunction](#can-i-subclass-basic-types-such-as-timefunction) - [How can I change the compilation flags (for example, I want to change the optimization level from -O3 to -O0)](#how-can-i-change-the-compilation-flags-for-example-i-want-to-change-the-optimization-level-from--o3-to--o0) - [Is the jitted code IEEE-compliant](#is-the-jitted-code-ieee-compliant) -- [Can I control the MPI domain decomposition?](#can-i-control-the-mpi-domain-decomposition) +- [Can I control the MPI domain decomposition](#can-i-control-the-mpi-domain-decomposition) - [How should I use MPI on multi-socket machines](#how-should-I-use-MPI-on-multi-socket-machines) - [How do I make sure my code is "MPI safe"](#how-do-i-make-sure-my-code-is-MPI-safe) - [Why does my Operator kernel die suddenly](#why-does-my-operator-kernel-die-suddenly) diff --git a/devito/logger.py b/devito/logger.py index 0ca9ec6aea9..edd87cc662a 100644 --- a/devito/logger.py +++ b/devito/logger.py @@ -77,7 +77,7 @@ def set_log_level(level, comm=None): """ from devito import configuration - if comm is not None: + if comm is not None and configuration['mpi']: 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 406f3bdeb98..552885fea92 100644 --- a/devito/operator/operator.py +++ b/devito/operator/operator.py @@ -5,6 +5,7 @@ from cached_property import cached_property import ctypes +from devito import switchconfig from devito.arch import compiler_registry, platform_registry from devito.data import default_allocator from devito.exceptions import InvalidOperator @@ -856,8 +857,10 @@ def apply(self, **kwargs): # Post-process runtime arguments self._postprocess_arguments(args, **kwargs) - # Output summary of performance achieved - return self._emit_apply_profiling(args) + # Output summary of performance achieved and + # temporarily drop MPI for printing arguments + with switchconfig(mpi=False): + return self._emit_apply_profiling(args) # Performance profiling @@ -895,10 +898,8 @@ def _emit_timings(timings, indent=''): def _emit_apply_profiling(self, args): """Produce a performance summary of the profiled sections.""" - # In case 'MPI0' is selected for logging, restrict result printing to one rank - temp = configuration['log-level'] - if configuration['mpi']: - set_log_level(configuration['log-level'], comm=args.comm) + # 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 @@ -993,16 +994,7 @@ def lower_perfentry(v): if a in args: perf_args[a] = args[a] break - - if configuration['mpi']: - perf("Performance[mode=%s, mpi=%s] arguments: %s, " % - (self._mode, configuration['mpi'], perf_args)) - else: - perf("Performance[mode=%s] arguments: %s" % (self._mode, perf_args)) - - # Restore logging configuration to all ranks - if configuration['mpi']: - set_log_level(temp, comm=None) + perf("Performance[mode=%s] arguments: %s" % (self._mode, perf_args)) return summary diff --git a/devito/operator/profiling.py b/devito/operator/profiling.py index fd0defd0893..62d842398a7 100644 --- a/devito/operator/profiling.py +++ b/devito/operator/profiling.py @@ -473,7 +473,7 @@ def add_glb_vanilla(self, key, time): ops = sum(v.ops for v in self.input.values()) traffic = sum(v.traffic for v in self.input.values()) - if np.isnan(traffic): + if np.isnan(traffic) or traffic == 0: return gflops = float(ops)/10**9