diff --git a/setup.py b/setup.py index 9e4494d..f3742fa 100644 --- a/setup.py +++ b/setup.py @@ -32,13 +32,14 @@ # SPDX-License-Identifier: BSD-3-Clause import os import re + import setuptools def read_file(*path): """Read file content.""" package_path = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join(package_path, *path), 'r') as text_file: + with open(os.path.join(package_path, *path)) as text_file: return text_file.read() diff --git a/stencil_benchmarks/benchmarks_collection/stencils/base.py b/stencil_benchmarks/benchmarks_collection/stencils/base.py index 1cbf36f..a45188c 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/base.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/base.py @@ -368,11 +368,11 @@ def __setitem__(self, index, value): if not self.all_components: (ustage, upos, utens, utensstage, wcon, ccol, dcol, - datacol) = [Wrapper(data) for data in data_before] + datacol) = (Wrapper(data) for data in data_before) else: (ustage, upos, utens, utensstage, vstage, vpos, vtens, vtensstage, wstage, wpos, wtens, wtensstage, wcon, ccol, dcol, - datacol) = [Wrapper(data) for data in data_before] + datacol) = (Wrapper(data) for data in data_before) dtr_stage = 3 / 20 beta_v = 0 diff --git a/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/__init__.py b/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/__init__.py index 3655cd9..91cc858 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/__init__.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/__init__.py @@ -30,8 +30,6 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -from . import basic -from . import horizontal_diffusion -from . import vertical_advection +from . import basic, horizontal_diffusion, vertical_advection __all__ = ['basic', 'horizontal_diffusion', 'vertical_advection'] diff --git a/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/horizontal_diffusion.py b/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/horizontal_diffusion.py index f3a046d..4b7619b 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/horizontal_diffusion.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/horizontal_diffusion.py @@ -33,8 +33,8 @@ from stencil_benchmarks.benchmark import Parameter from stencil_benchmarks.benchmarks_collection.stencils import base -from .mixin import StencilMixin from .basic import BasicStencilMixin +from .mixin import StencilMixin class HorizontalDiffusionMixin(StencilMixin): diff --git a/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/mixin.py b/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/mixin.py index 0b3b334..8f6ef56 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/mixin.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/cuda_hip/mixin.py @@ -36,9 +36,14 @@ import os import warnings -from stencil_benchmarks.benchmark import (Benchmark, ExecutionError, Parameter, - ParameterError) -from stencil_benchmarks.tools import array, cpphelpers, compilation, template +from stencil_benchmarks.benchmark import ( + Benchmark, + ExecutionError, + Parameter, + ParameterError, +) +from stencil_benchmarks.tools import array, compilation, cpphelpers, template + from . import api diff --git a/stencil_benchmarks/benchmarks_collection/stencils/jax/basic.py b/stencil_benchmarks/benchmarks_collection/stencils/jax/basic.py index c23f0e2..1212b5f 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/jax/basic.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/jax/basic.py @@ -33,8 +33,9 @@ import numpy as np from stencil_benchmarks.benchmark import Parameter -from .mixin import StencilMixin + from .. import base +from .mixin import StencilMixin class BasicStencilMixin(StencilMixin): @@ -96,7 +97,8 @@ class Laplacian(BasicStencilMixin, base.LaplacianStencil): choices=['pad', 'set', 'roll', 'convolve']) def stencil_definition(self): - from jax import numpy as jnp, scipy as jsp + from jax import numpy as jnp + from jax import scipy as jsp along_axes = (self.along_x, self.along_y, self.along_z) diff --git a/stencil_benchmarks/benchmarks_collection/stencils/jax/horizontal_diffusion.py b/stencil_benchmarks/benchmarks_collection/stencils/jax/horizontal_diffusion.py index e4bdf0d..2243c79 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/jax/horizontal_diffusion.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/jax/horizontal_diffusion.py @@ -30,8 +30,8 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -from .mixin import StencilMixin from .. import base +from .mixin import StencilMixin class HdiffStencilMixin(StencilMixin): @@ -84,7 +84,8 @@ def stencil(inp, coeff, out): class Vmapped(HdiffStencilMixin, base.HorizontalDiffusionStencil): def stencil_definition(self): - from jax import numpy as jnp, vmap + from jax import numpy as jnp + from jax import vmap def plane(inp, coeff): lap = 4 * inp[1:-1, 1:-1] - (inp[2:, 1:-1] + inp[:-2, 1:-1] + diff --git a/stencil_benchmarks/benchmarks_collection/stencils/jax/vertical_advection.py b/stencil_benchmarks/benchmarks_collection/stencils/jax/vertical_advection.py index 906d910..47759a3 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/jax/vertical_advection.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/jax/vertical_advection.py @@ -31,8 +31,9 @@ # # SPDX-License-Identifier: BSD-3-Clause from stencil_benchmarks.benchmark import Parameter, ParameterError -from .mixin import StencilMixin + from .. import base +from .mixin import StencilMixin class VadvStencilMixin(StencilMixin): @@ -56,7 +57,8 @@ class PlaneLoop(VadvStencilMixin, base.VerticalAdvectionStencil): loop = Parameter('loop implementation', 'jax', choices=['jax', 'python']) def stencil_definition(self): - from jax import lax, numpy as jnp + from jax import lax + from jax import numpy as jnp dtr_stage = 3 / 20 beta_v = 0 @@ -175,7 +177,7 @@ def backward(k, args): utensstage = utensstage.data if self.loop == 'jax': _, utensstage = lax.fori_loop( - -(self.domain[2] - 2), -(-1), + -(self.domain[2] - 2), 1, lambda nk, args: backward(-nk, args), (datacol, utensstage)) else: @@ -191,7 +193,8 @@ class ColumnLoop(VadvStencilMixin, base.VerticalAdvectionStencil): loop = Parameter('loop implementation', 'jax', choices=['jax', 'python']) def stencil_definition(self): - from jax import lax, numpy as jnp, vmap + from jax import lax, vmap + from jax import numpy as jnp dtr_stage = 3 / 20 beta_v = 0 @@ -280,7 +283,7 @@ def backward(k, args): if self.loop == 'jax': _, utensstage = lax.fori_loop( - -(self.domain[2] - 2), -(-1), + -(self.domain[2] - 2), 1, lambda nk, args: backward(-nk, args), (datacol, utensstage)) else: diff --git a/stencil_benchmarks/benchmarks_collection/stencils/numba_cpu/basic.py b/stencil_benchmarks/benchmarks_collection/stencils/numba_cpu/basic.py index ef03d46..53cfd12 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/numba_cpu/basic.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/numba_cpu/basic.py @@ -30,8 +30,8 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -from .. import base from ....tools import timing +from .. import base # pylint: disable=not-an-iterable diff --git a/stencil_benchmarks/benchmarks_collection/stencils/numpy/__init__.py b/stencil_benchmarks/benchmarks_collection/stencils/numpy/__init__.py index f57e6f2..14e3c9d 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/numpy/__init__.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/numpy/__init__.py @@ -30,7 +30,6 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -from . import basic -from . import horizontal_diffusion +from . import basic, horizontal_diffusion __all__ = ['basic', 'horizontal_diffusion'] diff --git a/stencil_benchmarks/benchmarks_collection/stencils/numpy/basic.py b/stencil_benchmarks/benchmarks_collection/stencils/numpy/basic.py index d1bf882..0d67e28 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/numpy/basic.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/numpy/basic.py @@ -32,9 +32,13 @@ # SPDX-License-Identifier: BSD-3-Clause import numpy as np -from ..base import (CopyStencil, OnesidedAverageStencil, - SymmetricAverageStencil, LaplacianStencil) from ....tools import timing +from ..base import ( + CopyStencil, + LaplacianStencil, + OnesidedAverageStencil, + SymmetricAverageStencil, +) class Copy1D(CopyStencil): diff --git a/stencil_benchmarks/benchmarks_collection/stencils/numpy/horizontal_diffusion.py b/stencil_benchmarks/benchmarks_collection/stencils/numpy/horizontal_diffusion.py index cfbab58..096f929 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/numpy/horizontal_diffusion.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/numpy/horizontal_diffusion.py @@ -32,8 +32,8 @@ # SPDX-License-Identifier: BSD-3-Clause import numpy as np -from ..base import HorizontalDiffusionStencil from ....tools import timing +from ..base import HorizontalDiffusionStencil class OnTheFly(HorizontalDiffusionStencil): diff --git a/stencil_benchmarks/benchmarks_collection/stencils/openmp/__init__.py b/stencil_benchmarks/benchmarks_collection/stencils/openmp/__init__.py index 3655cd9..91cc858 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/openmp/__init__.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/openmp/__init__.py @@ -30,8 +30,6 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -from . import basic -from . import horizontal_diffusion -from . import vertical_advection +from . import basic, horizontal_diffusion, vertical_advection __all__ = ['basic', 'horizontal_diffusion', 'vertical_advection'] diff --git a/stencil_benchmarks/benchmarks_collection/stencils/openmp/basic.py b/stencil_benchmarks/benchmarks_collection/stencils/openmp/basic.py index 51c9457..65a2092 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/openmp/basic.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/openmp/basic.py @@ -66,7 +66,7 @@ def stencil_body_vec(self): body = re.sub( r'out\[index\] = ([^;]*)', r'storent(&out[index], \1)' if self.streaming_stores else r'store(&out[index], \1)', body, - re.MULTILINE | re.DOTALL) + flags=re.MULTILINE | re.DOTALL) return body def template_file(self): diff --git a/stencil_benchmarks/benchmarks_collection/stencils/openmp/horizontal_diffusion.py b/stencil_benchmarks/benchmarks_collection/stencils/openmp/horizontal_diffusion.py index 86b4bf3..548ee27 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/openmp/horizontal_diffusion.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/openmp/horizontal_diffusion.py @@ -33,8 +33,8 @@ from stencil_benchmarks.benchmark import Parameter from stencil_benchmarks.benchmarks_collection.stencils import base -from .mixin import StencilMixin from .basic import BasicStencilMixin +from .mixin import StencilMixin class HorizontalDiffusionMixin(StencilMixin): diff --git a/stencil_benchmarks/benchmarks_collection/stencils/openmp/mixin.py b/stencil_benchmarks/benchmarks_collection/stencils/openmp/mixin.py index 3d63581..8bad7e6 100644 --- a/stencil_benchmarks/benchmarks_collection/stencils/openmp/mixin.py +++ b/stencil_benchmarks/benchmarks_collection/stencils/openmp/mixin.py @@ -36,7 +36,7 @@ import warnings from stencil_benchmarks.benchmark import Benchmark, ExecutionError, Parameter -from stencil_benchmarks.tools import cpphelpers, compilation, template +from stencil_benchmarks.tools import compilation, cpphelpers, template class StencilMixin(Benchmark): diff --git a/stencil_benchmarks/benchmarks_collection/stream/__init__.py b/stencil_benchmarks/benchmarks_collection/stream/__init__.py index 15587da..c148f76 100644 --- a/stencil_benchmarks/benchmarks_collection/stream/__init__.py +++ b/stencil_benchmarks/benchmarks_collection/stream/__init__.py @@ -30,6 +30,6 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -from . import mc_calpin, cuda_hip +from . import cuda_hip, mc_calpin __all__ = ['mc_calpin', 'cuda_hip'] diff --git a/stencil_benchmarks/benchmarks_collection/stream/cuda_hip.py b/stencil_benchmarks/benchmarks_collection/stream/cuda_hip.py index 8cbc7fe..7bfd777 100644 --- a/stencil_benchmarks/benchmarks_collection/stream/cuda_hip.py +++ b/stencil_benchmarks/benchmarks_collection/stream/cuda_hip.py @@ -34,7 +34,7 @@ import re import warnings -from ...benchmark import Benchmark, Parameter, ExecutionError +from ...benchmark import Benchmark, ExecutionError, Parameter from ...tools import compilation, cpphelpers, template diff --git a/stencil_benchmarks/benchmarks_collection/stream/mc_calpin.py b/stencil_benchmarks/benchmarks_collection/stream/mc_calpin.py index e8af96a..97321e3 100644 --- a/stencil_benchmarks/benchmarks_collection/stream/mc_calpin.py +++ b/stencil_benchmarks/benchmarks_collection/stream/mc_calpin.py @@ -35,7 +35,7 @@ import numpy as np -from ...benchmark import Benchmark, Parameter, ParameterError, ExecutionError +from ...benchmark import Benchmark, ExecutionError, Parameter, ParameterError from ...tools import compilation, cpphelpers, template diff --git a/stencil_benchmarks/cli.py b/stencil_benchmarks/cli.py index 52b0bde..0b12a9b 100644 --- a/stencil_benchmarks/cli.py +++ b/stencil_benchmarks/cli.py @@ -40,7 +40,8 @@ import click from . import benchmark -from .tools import cli as cli_tools, validation +from .tools import cli as cli_tools +from .tools import validation def _cli_command(bmark): diff --git a/stencil_benchmarks/scripts/sbench_a100_collection.py b/stencil_benchmarks/scripts/sbench_a100_collection.py index 0c2631c..08f31c2 100644 --- a/stencil_benchmarks/scripts/sbench_a100_collection.py +++ b/stencil_benchmarks/scripts/sbench_a100_collection.py @@ -33,12 +33,19 @@ import click +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import basic from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain, - default_kwargs) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( + vertical_advection as vadv, +) +from stencil_benchmarks.tools.multirun import ( + Configuration, + default_kwargs, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/scripts/sbench_a64fx_collection.py b/stencil_benchmarks/scripts/sbench_a64fx_collection.py index 6467fbd..470fdf3 100644 --- a/stencil_benchmarks/scripts/sbench_a64fx_collection.py +++ b/stencil_benchmarks/scripts/sbench_a64fx_collection.py @@ -36,15 +36,28 @@ import click import numpy as np +from stencil_benchmarks.benchmarks_collection.stencils.openmp import basic from stencil_benchmarks.benchmarks_collection.stencils.openmp import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.openmp import ( + vertical_advection as vadv, +) +from stencil_benchmarks.benchmarks_collection.stencils.openmp_blocked import ( + basic as basic_blocked, +) +from stencil_benchmarks.benchmarks_collection.stencils.openmp_blocked import ( + horizontal_diffusion as hdiff_blocked, +) from stencil_benchmarks.benchmarks_collection.stencils.openmp_blocked import ( - basic as basic_blocked, horizontal_diffusion as hdiff_blocked, - vertical_advection as vadv_blocked) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain) + vertical_advection as vadv_blocked, +) from stencil_benchmarks.tools import alloc +from stencil_benchmarks.tools.multirun import ( + Configuration, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/scripts/sbench_analyze.py b/stencil_benchmarks/scripts/sbench_analyze.py index 5d324db..70a4dbb 100644 --- a/stencil_benchmarks/scripts/sbench_analyze.py +++ b/stencil_benchmarks/scripts/sbench_analyze.py @@ -171,8 +171,9 @@ def plot(csv, uniform, ylim, title, auto_group, group, select, filter, X is the data column name for the values used for the x-axis in the plot, Y is the column name for the y-axis. """ - from matplotlib import pyplot as plt, ticker import cycler + from matplotlib import pyplot as plt + from matplotlib import ticker if output: plt.switch_backend('Agg') elif ascii: diff --git a/stencil_benchmarks/scripts/sbench_h100_collection.py b/stencil_benchmarks/scripts/sbench_h100_collection.py index 71b7f40..fb91d37 100644 --- a/stencil_benchmarks/scripts/sbench_h100_collection.py +++ b/stencil_benchmarks/scripts/sbench_h100_collection.py @@ -33,12 +33,19 @@ import click +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import basic from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain, - default_kwargs) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( + vertical_advection as vadv, +) +from stencil_benchmarks.tools.multirun import ( + Configuration, + default_kwargs, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/scripts/sbench_mi100_collection.py b/stencil_benchmarks/scripts/sbench_mi100_collection.py index ca96336..dd5a93c 100644 --- a/stencil_benchmarks/scripts/sbench_mi100_collection.py +++ b/stencil_benchmarks/scripts/sbench_mi100_collection.py @@ -33,12 +33,19 @@ import click +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import basic from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain, - default_kwargs) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( + vertical_advection as vadv, +) +from stencil_benchmarks.tools.multirun import ( + Configuration, + default_kwargs, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/scripts/sbench_mi50_collection.py b/stencil_benchmarks/scripts/sbench_mi50_collection.py index 68ed22a..84c14d4 100644 --- a/stencil_benchmarks/scripts/sbench_mi50_collection.py +++ b/stencil_benchmarks/scripts/sbench_mi50_collection.py @@ -33,12 +33,19 @@ import click +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import basic from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain, - default_kwargs) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( + vertical_advection as vadv, +) +from stencil_benchmarks.tools.multirun import ( + Configuration, + default_kwargs, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/scripts/sbench_p100_collection.py b/stencil_benchmarks/scripts/sbench_p100_collection.py index 4eb8f45..50e4ca7 100644 --- a/stencil_benchmarks/scripts/sbench_p100_collection.py +++ b/stencil_benchmarks/scripts/sbench_p100_collection.py @@ -33,12 +33,19 @@ import click +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import basic from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain, - default_kwargs) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( + vertical_advection as vadv, +) +from stencil_benchmarks.tools.multirun import ( + Configuration, + default_kwargs, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/scripts/sbench_rome_collection.py b/stencil_benchmarks/scripts/sbench_rome_collection.py index d7abd31..2f7cc14 100644 --- a/stencil_benchmarks/scripts/sbench_rome_collection.py +++ b/stencil_benchmarks/scripts/sbench_rome_collection.py @@ -36,15 +36,28 @@ import click import numpy as np +from stencil_benchmarks.benchmarks_collection.stencils.openmp import basic from stencil_benchmarks.benchmarks_collection.stencils.openmp import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.openmp import ( + vertical_advection as vadv, +) +from stencil_benchmarks.benchmarks_collection.stencils.openmp_blocked import ( + basic as basic_blocked, +) +from stencil_benchmarks.benchmarks_collection.stencils.openmp_blocked import ( + horizontal_diffusion as hdiff_blocked, +) from stencil_benchmarks.benchmarks_collection.stencils.openmp_blocked import ( - basic as basic_blocked, horizontal_diffusion as hdiff_blocked, - vertical_advection as vadv_blocked) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain) + vertical_advection as vadv_blocked, +) from stencil_benchmarks.tools import alloc +from stencil_benchmarks.tools.multirun import ( + Configuration, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/scripts/sbench_v100_collection.py b/stencil_benchmarks/scripts/sbench_v100_collection.py index 1973545..132494a 100644 --- a/stencil_benchmarks/scripts/sbench_v100_collection.py +++ b/stencil_benchmarks/scripts/sbench_v100_collection.py @@ -33,12 +33,19 @@ import click +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import basic from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( - basic, horizontal_diffusion as hdiff, vertical_advection as vadv) -from stencil_benchmarks.tools.multirun import (Configuration, - run_scaling_benchmark, - truncate_block_size_to_domain, - default_kwargs) + horizontal_diffusion as hdiff, +) +from stencil_benchmarks.benchmarks_collection.stencils.cuda_hip import ( + vertical_advection as vadv, +) +from stencil_benchmarks.tools.multirun import ( + Configuration, + default_kwargs, + run_scaling_benchmark, + truncate_block_size_to_domain, +) @click.group() diff --git a/stencil_benchmarks/tools/array.py b/stencil_benchmarks/tools/array.py index fc9716d..ca56dc7 100644 --- a/stencil_benchmarks/tools/array.py +++ b/stencil_benchmarks/tools/array.py @@ -31,8 +31,8 @@ # # SPDX-License-Identifier: BSD-3-Clause import ctypes -from typing import Any, Callable, Optional, Tuple, Union import warnings +from typing import Any, Callable, Optional, Tuple, Union import numpy as np diff --git a/stencil_benchmarks/tools/cli.py b/stencil_benchmarks/tools/cli.py index 01ea747..e4d487c 100644 --- a/stencil_benchmarks/tools/cli.py +++ b/stencil_benchmarks/tools/cli.py @@ -37,8 +37,7 @@ import re import sys import types -from typing import (Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, - Tuple) +from typing import Any, Dict, Iterable, Iterator, List, NamedTuple, Optional, Tuple import click diff --git a/stencil_benchmarks/tools/compilation.py b/stencil_benchmarks/tools/compilation.py index fd983ae..2f6079b 100644 --- a/stencil_benchmarks/tools/compilation.py +++ b/stencil_benchmarks/tools/compilation.py @@ -37,9 +37,8 @@ import pathlib import subprocess import tempfile -from typing import (Any, Callable, Iterator, List, Optional, TextIO, Tuple, - Union) import warnings +from typing import Any, Callable, Iterator, List, Optional, TextIO, Tuple, Union import numpy as np @@ -83,8 +82,7 @@ def _capture_output(stdout: TextIO, stderr: TextIO) -> Iterator[None]: stderr : TextIO TextIO to capture stderr. """ - with _redirect_output(1, stdout): - with _redirect_output(2, stderr): + with _redirect_output(1, stdout), _redirect_output(2, stderr): yield @@ -130,7 +128,9 @@ def __init__(self, output_dir = pathlib.Path("benchmarks_source_code") output_dir.mkdir(exist_ok=True) - with tempfile.NamedTemporaryFile(suffix=extension, dir=output_dir, delete=False) as srcfile: + with tempfile.NamedTemporaryFile(suffix=extension, + dir=output_dir, + delete=False) as srcfile: srcfile.write(code.encode()) srcfile.flush() @@ -138,8 +138,7 @@ def __init__(self, result = subprocess.run( [compile_command[0], '-o', library.name, srcfile.name] + compile_command[1:], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + capture_output=True) if result.returncode != 0: raise CompilationError(result.stderr.decode()) if result.stdout or result.stderr: diff --git a/stencil_benchmarks/tools/cpphelpers.py b/stencil_benchmarks/tools/cpphelpers.py index 3b2e002..5f9c808 100644 --- a/stencil_benchmarks/tools/cpphelpers.py +++ b/stencil_benchmarks/tools/cpphelpers.py @@ -30,8 +30,8 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -import warnings import subprocess +import warnings def format_code(code: str, line_numbers: bool = True) -> str: diff --git a/stencil_benchmarks/tools/multirun.py b/stencil_benchmarks/tools/multirun.py index 818bfb2..77caa53 100644 --- a/stencil_benchmarks/tools/multirun.py +++ b/stencil_benchmarks/tools/multirun.py @@ -30,10 +30,10 @@ # POSSIBILITY OF SUCH DAMAGE. # # SPDX-License-Identifier: BSD-3-Clause -from ast import literal_eval import gc import re import warnings +from ast import literal_eval import pandas as pd