From 8efd2fc9a87463445911a8c888feb89e789d2f35 Mon Sep 17 00:00:00 2001 From: George Bisbas Date: Tue, 10 Oct 2023 14:45:54 +0100 Subject: [PATCH] docs: More updates from Archer2 --- devito/builtins/arithmetic.py | 12 ++++++------ devito/builtins/initializers.py | 2 +- devito/logger.py | 10 +++++++++- devito/mpi/distributed.py | 11 ++++++++++- devito/operator/operator.py | 9 ++++++++- devito/operator/profiling.py | 2 +- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/devito/builtins/arithmetic.py b/devito/builtins/arithmetic.py index 48df46e5ae..596ee2c256 100644 --- a/devito/builtins/arithmetic.py +++ b/devito/builtins/arithmetic.py @@ -22,7 +22,7 @@ } -@dv.switchconfig(log_level='ERROR') +#@dv.switchconfig(log_level='ERROR') def norm(f, order=2): """ Compute the norm of a Function. @@ -57,7 +57,7 @@ def norm(f, order=2): return f.dtype(v) -@dv.switchconfig(log_level='ERROR') +#@dv.switchconfig(log_level='ERROR') def sum(f, dims=None): """ Compute the sum of the Function data over specified dimensions. @@ -110,7 +110,7 @@ def sum(f, dims=None): return out -@dv.switchconfig(log_level='ERROR') +#@dv.switchconfig(log_level='ERROR') def sumall(f): """ Compute the sum of all Function data. @@ -140,7 +140,7 @@ def sumall(f): return f.dtype(mr.v) -@dv.switchconfig(log_level='ERROR') +#@dv.switchconfig(log_level='ERROR') def inner(f, g): """ Inner product of two Functions. @@ -195,7 +195,7 @@ def inner(f, g): return f.dtype(mr.v) -@dv.switchconfig(log_level='ERROR') +#@dv.switchconfig(log_level='ERROR') def mmin(f): """ Retrieve the minimum. @@ -215,7 +215,7 @@ def mmin(f): raise ValueError("Expected Function, not `%s`" % type(f)) -@dv.switchconfig(log_level='ERROR') +#@dv.switchconfig(log_level='ERROR') def mmax(f): """ Retrieve the maximum. diff --git a/devito/builtins/initializers.py b/devito/builtins/initializers.py index 83bad735fa..f5f1a30691 100644 --- a/devito/builtins/initializers.py +++ b/devito/builtins/initializers.py @@ -7,7 +7,7 @@ __all__ = ['assign', 'smooth', 'gaussian_smooth', 'initialize_function'] -@dv.switchconfig(log_level='ERROR') +#@dv.switchconfig(log_level='ERROR') def assign(f, rhs=0, options=None, name='assign', assign_halo=False, **kwargs): """ Assign a list of RHSs to a list of Functions. diff --git a/devito/logger.py b/devito/logger.py index 0ca9ec6aea..931cc94ac1 100644 --- a/devito/logger.py +++ b/devito/logger.py @@ -16,12 +16,15 @@ # Add extra logging levels (note: INFO has value=20, WARNING has value=30) DEBUG = logging.DEBUG PERF = 19 +BENCH = logging.DEBUG INFO = logging.INFO WARNING = logging.WARNING ERROR = logging.ERROR CRITICAL = logging.CRITICAL logging.addLevelName(PERF, "PERF") +logging.addLevelName(BENCH, "BENCH") + logger_registry = { 'DEBUG': DEBUG, @@ -29,7 +32,8 @@ 'INFO': INFO, 'WARNING': WARNING, 'ERROR': ERROR, - 'CRITICAL': CRITICAL + 'CRITICAL': CRITICAL, + 'BENCH': BENCH } NOCOLOR = '%s' @@ -136,6 +140,10 @@ def error(msg, *args, **kwargs): log(msg, ERROR, *args, **kwargs) +def bench(msg, *args, **kwargs): + log(msg, BENCH, *args, **kwargs) + + def debug(msg, *args, **kwargs): log(msg, DEBUG, *args, **kwargs) diff --git a/devito/mpi/distributed.py b/devito/mpi/distributed.py index 7a5ac80db2..ae109a7389 100644 --- a/devito/mpi/distributed.py +++ b/devito/mpi/distributed.py @@ -10,6 +10,7 @@ import numpy as np from cgen import Struct, Value +from devito.logger import set_log_level from devito.data import LEFT, CENTER, RIGHT, Decomposition from devito.parameters import configuration from devito.tools import EnrichedTuple, as_tuple, ctypes_to_cstr, filter_ordered @@ -192,11 +193,19 @@ def __init__(self, shape, dimensions, input_comm=None, topology=None): global init_by_devito init_by_devito = True + # If BENCH logging is selected, only emit from rank 0 + if configuration['log-level'] == 'BENCH': + set_log_level('DEBUG', comm=MPI.COMM_WORLD) + # Note: the cloned communicator doesn't need to be explicitly freed; # mpi4py takes care of that when the object gets out of scope self._input_comm = (input_comm or MPI.COMM_WORLD).Clone() - topology = ('*', '*', 1) + # if len(shape) == 3: + # topology = ('*', '*', 1) + + # topology = ('*', '*', 1) + # topology = ('*', '*', 8) if topology is None: # `MPI.Compute_dims` sets the dimension sizes to be as close to each other diff --git a/devito/operator/operator.py b/devito/operator/operator.py index 36ac147e9d..4560d7a50e 100644 --- a/devito/operator/operator.py +++ b/devito/operator/operator.py @@ -989,7 +989,14 @@ def lower_perfentry(v): if a in args: perf_args[a] = args[a] break - perf("Performance[mode=%s] arguments: %s" % (self._mode, perf_args)) + + 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)) + + # 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 53f16e526f..ade8197f6f 100644 --- a/devito/operator/profiling.py +++ b/devito/operator/profiling.py @@ -521,7 +521,7 @@ def timings(self): def create_profile(name): """Create a new Profiler.""" - if configuration['log-level'] in ['DEBUG', 'PERF'] and \ + if configuration['log-level'] in ['DEBUG', 'PERF', 'BENCH'] and \ configuration['profiling'] == 'basic': # Enforce performance profiling in DEBUG mode level = 'advanced'