From 73a6c634e2cd340e8e4805bef69cd68cb2417363 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Mon, 26 Jun 2023 18:27:32 -0500 Subject: [PATCH 01/17] factor out actx init --- examples/wave-mpi.py | 52 ++++++++++++++--------------------- examples/wave.py | 51 ++++++++-------------------------- mirgecom/simutil.py | 65 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 96 insertions(+), 72 deletions(-) diff --git a/examples/wave-mpi.py b/examples/wave-mpi.py index b9f25f4d9..2e50fc849 100644 --- a/examples/wave-mpi.py +++ b/examples/wave-mpi.py @@ -23,29 +23,24 @@ """ import logging +import grudge.op as op import numpy as np import numpy.linalg as la # noqa import pyopencl as cl - -from pytools.obj_array import flat_obj_array - -from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa - from grudge.shortcuts import make_visualizer -import grudge.op as op +from logpyle import IntervalTimer, set_dt +from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa +from pytools.obj_array import flat_obj_array from mirgecom.discretization import create_discretization_collection -from mirgecom.mpi import mpi_entry_point from mirgecom.integrators import rk4_step -from mirgecom.wave import wave_operator -from mirgecom.utils import force_evaluation - -from logpyle import IntervalTimer, set_dt - from mirgecom.logging_quantities import (initialize_logmgr, logmgr_add_cl_device_info, logmgr_add_device_memory_usage, - logmgr_add_mempool_usage,) + logmgr_add_mempool_usage) +from mirgecom.mpi import mpi_entry_point +from mirgecom.utils import force_evaluation +from mirgecom.wave import wave_operator def bump(actx, nodes, t=0): @@ -69,7 +64,7 @@ def bump(actx, nodes, t=0): @mpi_entry_point def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", - restart_step=None, use_profiling=False, use_logmgr=False, lazy=False): + restart_step=None, use_logmgr: bool = False) -> None: """Drive the example.""" cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) @@ -81,23 +76,15 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", logmgr = initialize_logmgr(use_logmgr, filename="wave-mpi.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue(cl_ctx, - properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + use_profiling = actx_class_is_profiling(actx_class) if restart_step is None: - from meshmode.distributed import MPIMeshDistributor, get_partition_by_pymetis + from meshmode.distributed import (MPIMeshDistributor, + get_partition_by_pymetis) mesh_dist = MPIMeshDistributor(comm) dim = 2 @@ -161,7 +148,8 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", if old_order != order: old_dcoll = create_discretization_collection( actx, local_mesh, order=old_order) - from meshmode.discretization.connection import make_same_mesh_connection + from meshmode.discretization.connection import \ + make_same_mesh_connection connection = make_same_mesh_connection(actx, dcoll.discr_from_dd("vol"), old_dcoll.discr_from_dd("vol")) fields = connection(restart_fields) @@ -264,9 +252,11 @@ def rhs(t, w): args = parser.parse_args() lazy = args.lazy - from grudge.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.simutil import get_reasonable_array_context_class + actx_class = get_reasonable_array_context_class(lazy=lazy, + distributed=True, + profiling=args.profiling) - main(actx_class, use_profiling=args.profiling, use_logmgr=args.log, lazy=lazy) + main(actx_class, use_logmgr=args.log) # vim: foldmethod=marker diff --git a/examples/wave.py b/examples/wave.py index e1105bdf9..86d3fcd27 100644 --- a/examples/wave.py +++ b/examples/wave.py @@ -22,29 +22,20 @@ THE SOFTWARE. """ +import grudge.op as op import numpy as np -import numpy.linalg as la # noqa -import pyopencl as cl -import pyopencl.array as cla # noqa - -from pytools.obj_array import flat_obj_array - from grudge.shortcuts import make_visualizer -import grudge.op as op +from logpyle import IntervalTimer, set_dt +from pytools.obj_array import flat_obj_array from mirgecom.discretization import create_discretization_collection -from mirgecom.wave import wave_operator from mirgecom.integrators import rk4_step -from mirgecom.utils import force_evaluation - -from mirgecom.profiling import PyOpenCLProfilingArrayContext - -from logpyle import IntervalTimer, set_dt - from mirgecom.logging_quantities import (initialize_logmgr, logmgr_add_cl_device_info, logmgr_add_device_memory_usage, logmgr_add_mempool_usage) +from mirgecom.utils import force_evaluation +from mirgecom.wave import wave_operator def bump(actx, nodes, t=0): @@ -66,32 +57,14 @@ def bump(actx, nodes, t=0): / source_width**2)) -def main(actx_class, use_profiling=False, use_logmgr=False, lazy: bool = False): +def main(actx_class, use_logmgr: bool = False) -> None: """Drive the example.""" - cl_ctx = cl.create_some_context() - logmgr = initialize_logmgr(use_logmgr, filename="wave.sqlite", mode="wu") - from mirgecom.simutil import get_reasonable_memory_pool - - if use_profiling: - if lazy: - raise RuntimeError("Cannot run lazy with profiling.") - queue = cl.CommandQueue(cl_ctx, - properties=cl.command_queue_properties.PROFILING_ENABLE) - - alloc = get_reasonable_memory_pool(cl_ctx, queue) - actx = PyOpenCLProfilingArrayContext(queue, allocator=alloc) - else: - queue = cl.CommandQueue(cl_ctx) - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(queue, allocator=alloc) - else: - actx = actx_class(queue, allocator=alloc, - force_device_scalars=True) + from mirgecom.simutil import actx_class_is_profiling, initialize_actx + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, None) + use_profiling = actx_class_is_profiling(actx_class) dim = 2 nel_1d = 16 @@ -189,9 +162,9 @@ def rhs(t, w): from grudge.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=args.lazy, - distributed=False) + distributed=False, + profiling=args.profiling) - main(actx_class, use_profiling=args.profiling, - use_logmgr=args.log, lazy=args.lazy) + main(actx_class, use_logmgr=args.log) # vim: foldmethod=marker diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index fe7c9cd74..4fc83676e 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -30,6 +30,11 @@ ---------------------------- .. autofunction:: configurate +.. autofunction:: get_reasonable_actx_class +.. autofunction:: actx_class_is_lazy +.. autofunction:: actx_class_is_eager +.. autofunction:: actx_class_is_profiling +.. autofunction:: initialize_actx File comparison utilities ------------------------- @@ -72,7 +77,7 @@ from meshmode.dof_array import DOFArray from mirgecom.viscous import get_viscous_timestep -from typing import List, Dict, Optional +from typing import List, Dict, Optional, Tuple, Any from grudge.discretization import DiscretizationCollection, PartID from grudge.dof_desc import DD_VOLUME_ALL from mirgecom.utils import normalize_boundaries @@ -103,7 +108,7 @@ def check_step(step, interval): - Zero means 'always visualize'. Useful for checking whether the current step is an output step, - or anyting else that occurs on fixed intervals. + or anything else that occurs on fixed intervals. """ if interval == 0: return True @@ -1129,6 +1134,62 @@ def configurate(config_key, config_object=None, default_value=None): return default_value +def get_reasonable_actx_class(lazy: bool = False, distributed: bool = True, + profiling: bool = False): + if lazy and profiling: + raise ValueError("Can't specify both lazy and profiling") + + if profiling: + from mirgecom.profiling import PyOpenCLProfilingArrayContext + return PyOpenCLProfilingArrayContext + + from grudge.array_context import (get_reasonable_actx_class as + grudge_get_reasonable_actx_class) + + return grudge_get_reasonable_actx_class(lazy=lazy, distributed=distributed) + + +def actx_class_is_lazy(actx_class) -> bool: + from arraycontext import PytatoPyOpenCLArrayContext + return issubclass(actx_class, PytatoPyOpenCLArrayContext) + + +def actx_class_is_eager(actx_class) -> bool: + from arraycontext import PyOpenCLArrayContext + return issubclass(actx_class, PyOpenCLArrayContext) + + +def actx_class_is_profiling(actx_class) -> bool: + from mirgecom.profiling import PyOpenCLProfilingArrayContext + return issubclass(actx_class, PyOpenCLProfilingArrayContext) + + +def initialize_actx(actx_class, comm) -> Tuple[Any]: + cl_ctx = cl.create_some_context() + if actx_class_is_profiling(actx_class): + queue = cl.CommandQueue(cl_ctx, + properties=cl.command_queue_properties.PROFILING_ENABLE) + else: + queue = cl.CommandQueue(cl_ctx) + + alloc = get_reasonable_memory_pool(cl_ctx, queue) + + if actx_class_is_lazy(actx_class): + if comm: + actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) + else: + actx = actx_class(queue, allocator=alloc) + else: + assert actx_class_is_eager(actx_class) + if comm: + actx = actx_class(comm, queue, allocator=alloc, + force_device_scalars=True) + else: + actx = actx_class(queue, allocator=alloc, force_device_scalars=True) + + return actx, cl_ctx, queue, alloc + + def compare_files_vtu( first_file: str, second_file: str, From b8155968864d67986a0e752e0bddc2922ae7fdee Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Tue, 27 Jun 2023 15:32:13 -0500 Subject: [PATCH 02/17] typing fixes --- examples/wave-mpi.py | 6 +++--- examples/wave.py | 4 +++- mirgecom/simutil.py | 33 ++++++++++++++++++++++----------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/examples/wave-mpi.py b/examples/wave-mpi.py index 2e50fc849..4f71d8b16 100644 --- a/examples/wave-mpi.py +++ b/examples/wave-mpi.py @@ -78,7 +78,7 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", filename="wave-mpi.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) use_profiling = actx_class_is_profiling(actx_class) if restart_step is None: @@ -126,7 +126,7 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", from grudge.dt_utils import characteristic_lengthscales nodal_dt = characteristic_lengthscales(actx, dcoll) / wave_speed - dt = actx.to_numpy(current_cfl * op.nodal_min(dcoll, "vol", nodal_dt))[()] + dt = actx.to_numpy(current_cfl * op.nodal_min(dcoll, "vol", nodal_dt))[()] # type: ignore[index] t_final = 1 @@ -235,7 +235,7 @@ def rhs(t, w): logmgr.close() final_soln = actx.to_numpy(op.norm(dcoll, fields[0], 2)) - assert np.abs(final_soln - 0.04409852463947439) < 1e-14 + assert np.abs(final_soln - 0.04409852463947439) < 1e-14 # type: ignore[operator] if __name__ == "__main__": diff --git a/examples/wave.py b/examples/wave.py index 86d3fcd27..c152484cc 100644 --- a/examples/wave.py +++ b/examples/wave.py @@ -85,7 +85,7 @@ def main(actx_class, use_logmgr: bool = False) -> None: from grudge.dt_utils import characteristic_lengthscales nodal_dt = characteristic_lengthscales(actx, dcoll) / wave_speed dt = actx.to_numpy(current_cfl * op.nodal_min(dcoll, "vol", - nodal_dt))[()] + nodal_dt))[()] # type: ignore[index] print("%d elements" % mesh.nelements) @@ -130,6 +130,8 @@ def rhs(t, w): if istep % 10 == 0: if use_profiling: + from mirgecom.profiling import PyOpenCLProfilingArrayContext + assert isinstance(actx, PyOpenCLProfilingArrayContext) print(actx.tabulate_profiling_data()) print(istep, t, actx.to_numpy(op.norm(dcoll, fields[0], 2))) vis.write_vtk_file("fld-wave-%04d.vtu" % istep, diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index 4fc83676e..cdb063e0a 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -30,7 +30,7 @@ ---------------------------- .. autofunction:: configurate -.. autofunction:: get_reasonable_actx_class +.. autofunction:: get_reasonable_array_context_class .. autofunction:: actx_class_is_lazy .. autofunction:: actx_class_is_eager .. autofunction:: actx_class_is_profiling @@ -72,12 +72,12 @@ from functools import partial import grudge.op as op -# from grudge.op import nodal_min, elementwise_min -from arraycontext import map_array_container, flatten + +from arraycontext import map_array_container, flatten, ArrayContext from meshmode.dof_array import DOFArray from mirgecom.viscous import get_viscous_timestep -from typing import List, Dict, Optional, Tuple, Any +from typing import List, Dict, Optional, Tuple, Any, TYPE_CHECKING, Type from grudge.discretization import DiscretizationCollection, PartID from grudge.dof_desc import DD_VOLUME_ALL from mirgecom.utils import normalize_boundaries @@ -85,6 +85,9 @@ logger = logging.getLogger(__name__) +if TYPE_CHECKING: + from mpi4py.MPI import Comm + def get_number_of_tetrahedron_nodes(dim, order, include_faces=False): """Get number of nodes (modes) in *dim* Tetrahedron of *order*.""" @@ -211,7 +214,7 @@ def get_sim_timestep( def write_visfile(dcoll, io_fields, visualizer, vizname, step=0, t=0, overwrite=False, vis_timer=None, - comm=None): + comm: Optional["Comm"] = None): """Write parallel VTK output for the fields specified in *io_fields*. This routine writes a parallel-compatible unstructured VTK visualization @@ -1134,7 +1137,7 @@ def configurate(config_key, config_object=None, default_value=None): return default_value -def get_reasonable_actx_class(lazy: bool = False, distributed: bool = True, +def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, profiling: bool = False): if lazy and profiling: raise ValueError("Can't specify both lazy and profiling") @@ -1164,7 +1167,10 @@ def actx_class_is_profiling(actx_class) -> bool: return issubclass(actx_class, PyOpenCLProfilingArrayContext) -def initialize_actx(actx_class, comm) -> Tuple[Any]: +def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) -> Tuple[ArrayContext, cl.Context, cl.CommandQueue, cl.tools.AllocatorBase]: + from arraycontext import PytatoPyOpenCLArrayContext, PyOpenCLArrayContext + from grudge.array_context import MPIPyOpenCLArrayContext, MPIPytatoPyOpenCLArrayContext + cl_ctx = cl.create_some_context() if actx_class_is_profiling(actx_class): queue = cl.CommandQueue(cl_ctx, @@ -1175,16 +1181,21 @@ def initialize_actx(actx_class, comm) -> Tuple[Any]: alloc = get_reasonable_memory_pool(cl_ctx, queue) if actx_class_is_lazy(actx_class): + assert issubclass(actx_class, PytatoPyOpenCLArrayContext) if comm: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) + assert issubclass(actx_class, MPIPytatoPyOpenCLArrayContext) + actx: ArrayContext = actx_class(mpi_communicator=comm, queue=queue, mpi_base_tag=12000, allocator=alloc) # type: ignore[call-arg] else: + assert not issubclass(actx_class, MPIPytatoPyOpenCLArrayContext) actx = actx_class(queue, allocator=alloc) else: - assert actx_class_is_eager(actx_class) + assert issubclass(actx_class, PyOpenCLArrayContext) if comm: - actx = actx_class(comm, queue, allocator=alloc, - force_device_scalars=True) + assert issubclass(actx_class, MPIPyOpenCLArrayContext) + actx = actx_class(mpi_communicator=comm, queue=queue, allocator=alloc, + force_device_scalars=True) # type: ignore[call-arg] else: + assert not issubclass(actx_class, MPIPyOpenCLArrayContext) actx = actx_class(queue, allocator=alloc, force_device_scalars=True) return actx, cl_ctx, queue, alloc From f95c1f0310956a7eac168f7857223c6e621e1c5d Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Tue, 27 Jun 2023 18:30:05 -0500 Subject: [PATCH 03/17] other examples --- examples/autoignition-mpi.py | 20 +++++--------------- examples/combozzle-mpi.py | 20 ++++---------------- examples/doublemach-mpi.py | 24 +++++++----------------- examples/doublemach_physical_av-mpi.py | 16 +++------------- examples/heat-source-mpi.py | 23 ++++++----------------- examples/hotplate-mpi.py | 25 +++++++------------------ examples/lump-mpi.py | 23 ++++++----------------- examples/mixture-mpi.py | 24 +++++++----------------- examples/multiple-volumes-mpi.py | 20 +++++--------------- examples/nsmix-mpi.py | 24 +++++++----------------- examples/poiseuille-local_dt-mpi.py | 24 +++++++----------------- examples/poiseuille-mpi.py | 24 +++++++----------------- examples/pulse-mpi.py | 20 +++++--------------- examples/scalar-lump-mpi.py | 24 +++++++----------------- examples/sod-mpi.py | 22 ++++++---------------- examples/thermally-coupled-mpi.py | 24 +++++++----------------- examples/vortex-mpi.py | 23 ++++++----------------- 17 files changed, 102 insertions(+), 278 deletions(-) diff --git a/examples/autoignition-mpi.py b/examples/autoignition-mpi.py index 16dfe379b..b05f5783b 100644 --- a/examples/autoignition-mpi.py +++ b/examples/autoignition-mpi.py @@ -76,8 +76,8 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_overintegration=False, use_profiling=False, - casename=None, lazy=False, rst_filename=None, log_dependent=True, + use_leap=False, use_overintegration=False, + casename=None, rst_filename=None, log_dependent=True, viscous_terms_on=False): """Drive example.""" cl_ctx = ctx_factory() @@ -96,19 +96,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue(cl_ctx, - properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + use_profiling = actx_class_is_profiling(actx_class) # Some discretization parameters dim = 2 diff --git a/examples/combozzle-mpi.py b/examples/combozzle-mpi.py index 331c5608d..8c7413356 100644 --- a/examples/combozzle-mpi.py +++ b/examples/combozzle-mpi.py @@ -161,8 +161,7 @@ def __call__(self, x_vec, *, time=0.0): @mpi_entry_point def main(ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_overintegration=False, - use_profiling=False, casename=None, lazy=False, + use_overintegration=False, casename=None, rst_filename=None, actx_class=PyOpenCLArrayContext, log_dependent=False, input_file=None, force_eval=True): @@ -600,19 +599,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, print(f"ACTX setup start: {time.ctime(time.time())}") comm.Barrier() - if use_profiling: - queue = cl.CommandQueue(cl_ctx, - properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + use_profiling = actx_class_is_profiling(actx_class) rst_path = "restart_data/" rst_pattern = ( @@ -1308,7 +1297,6 @@ def dummy_rhs(t, state): main(use_logmgr=args.log, use_leap=args.leap, input_file=input_file, use_overintegration=args.overintegration, - use_profiling=args.profiling, lazy=lazy, casename=casename, rst_filename=rst_filename, actx_class=actx_class, log_dependent=log_dependent, force_eval=force_eval) diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index f249c7d80..5b90a7671 100644 --- a/examples/doublemach-mpi.py +++ b/examples/doublemach-mpi.py @@ -117,8 +117,8 @@ def get_doublemach_mesh(): @mpi_entry_point def main(ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, use_overintegration=False, - casename=None, rst_filename=None, actx_class=None, lazy=False): + use_leap=False, use_overintegration=False, + casename=None, rst_filename=None, actx_class=None): """Drive the example.""" if actx_class is None: raise RuntimeError("Array context class missing.") @@ -136,19 +136,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # Timestepping control current_step = 0 @@ -471,8 +461,8 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_leap=args.leap, use_profiling=args.profiling, - use_overintegration=args.overintegration, lazy=lazy, + main(use_logmgr=args.log, use_leap=args.leap, + use_overintegration=args.overintegration, casename=casename, rst_filename=rst_filename, actx_class=actx_class) # vim: foldmethod=marker diff --git a/examples/doublemach_physical_av-mpi.py b/examples/doublemach_physical_av-mpi.py index d667da451..b04d2e269 100644 --- a/examples/doublemach_physical_av-mpi.py +++ b/examples/doublemach_physical_av-mpi.py @@ -151,19 +151,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=logname, mode="wo", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # Timestepping control current_step = 0 diff --git a/examples/heat-source-mpi.py b/examples/heat-source-mpi.py index 37b208a7d..9d4c68e99 100644 --- a/examples/heat-source-mpi.py +++ b/examples/heat-source-mpi.py @@ -49,8 +49,7 @@ @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, lazy=False, - rst_filename=None): + use_leap=False, casename=None, rst_filename=None): """Run the example.""" cl_ctx = cl.create_some_context() queue = cl.CommandQueue(cl_ctx) @@ -62,19 +61,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename="heat-source.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) from meshmode.distributed import MPIMeshDistributor, get_partition_by_pymetis mesh_dist = MPIMeshDistributor(comm) @@ -218,7 +207,7 @@ def rhs(t, u): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_leap=args.leap, lazy=lazy, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename) + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/hotplate-mpi.py b/examples/hotplate-mpi.py index e08fda011..4c66a4eec 100644 --- a/examples/hotplate-mpi.py +++ b/examples/hotplate-mpi.py @@ -82,8 +82,8 @@ def _get_box_mesh(dim, a, b, n, t=None): @mpi_entry_point def main(ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, - rst_filename=None, actx_class=None, lazy=False): + use_leap=False, casename=None, + rst_filename=None, actx_class=None): """Drive the example.""" if actx_class is None: raise RuntimeError("Array context class missing.") @@ -104,19 +104,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control timestepper = rk4_step @@ -475,8 +465,7 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_leap=args.leap, use_profiling=args.profiling, - casename=casename, rst_filename=rst_filename, actx_class=actx_class, - lazy=lazy) + main(use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename, actx_class=actx_class) # vim: foldmethod=marker diff --git a/examples/lump-mpi.py b/examples/lump-mpi.py index b26d9a58f..9a3f44544 100644 --- a/examples/lump-mpi.py +++ b/examples/lump-mpi.py @@ -67,8 +67,7 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, lazy=False, - rst_filename=None): + use_leap=False, casename=None, rst_filename=None): """Drive example.""" cl_ctx = ctx_factory() @@ -86,19 +85,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue(cl_ctx, - properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control if use_leap: @@ -395,7 +384,7 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_leap=args.leap, lazy=lazy, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename) + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/mixture-mpi.py b/examples/mixture-mpi.py index 5a8215f78..c48c4c0d9 100644 --- a/examples/mixture-mpi.py +++ b/examples/mixture-mpi.py @@ -73,8 +73,8 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, rst_filename=None, - log_dependent=False, lazy=False): + use_leap=False, casename=None, rst_filename=None, + log_dependent=False): """Drive example.""" cl_ctx = ctx_factory() @@ -92,19 +92,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control if use_leap: @@ -474,8 +464,8 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_leap=args.leap, lazy=lazy, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename, + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename, log_dependent=log_dependent) # vim: foldmethod=marker diff --git a/examples/multiple-volumes-mpi.py b/examples/multiple-volumes-mpi.py index 67d466d80..953c75dc8 100644 --- a/examples/multiple-volumes-mpi.py +++ b/examples/multiple-volumes-mpi.py @@ -83,7 +83,7 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_overintegration=False, lazy=False, use_leap=False, use_profiling=False, + use_overintegration=False,use_leap=False, casename=None, rst_filename=None): """Drive the example.""" cl_ctx = ctx_factory() @@ -102,19 +102,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control current_step = 0 @@ -419,7 +409,7 @@ def my_rhs(t, state): rst_filename = args.restart_file main(actx_class, use_logmgr=args.log, use_overintegration=args.overintegration, - use_leap=args.leap, use_profiling=args.profiling, lazy=lazy, + use_leap=args.leap, casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/nsmix-mpi.py b/examples/nsmix-mpi.py index 4e88b1910..17c0790dd 100644 --- a/examples/nsmix-mpi.py +++ b/examples/nsmix-mpi.py @@ -79,8 +79,8 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, - rst_filename=None, actx_class=None, lazy=False, + use_leap=False, casename=None, + rst_filename=None, actx_class=None, log_dependent=True, use_overintegration=False): """Drive example.""" if actx_class is None: @@ -102,19 +102,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # Timestepping control # This example runs only 3 steps by default (to keep CI ~short) @@ -653,9 +643,9 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_leap=args.leap, use_profiling=args.profiling, + main(use_logmgr=args.log, use_leap=args.leap, casename=casename, rst_filename=rst_filename, actx_class=actx_class, - log_dependent=log_dependent, lazy=lazy, + log_dependent=log_dependent, use_overintegration=args.overintegration) # vim: foldmethod=marker diff --git a/examples/poiseuille-local_dt-mpi.py b/examples/poiseuille-local_dt-mpi.py index 0b04656cc..bf9ae0398 100644 --- a/examples/poiseuille-local_dt-mpi.py +++ b/examples/poiseuille-local_dt-mpi.py @@ -73,8 +73,8 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(ctx_factory=cl.create_some_context, use_logmgr=True, - use_overintegration=False, lazy=False, - use_leap=False, use_profiling=False, casename=None, + use_overintegration=False, + use_leap=False, casename=None, rst_filename=None, actx_class=None): """Drive the example.""" if actx_class is None: @@ -96,19 +96,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control timestepper = rk4_step @@ -509,8 +499,8 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_leap=args.leap, use_profiling=args.profiling, - use_overintegration=args.overintegration, lazy=lazy, + main(use_logmgr=args.log, use_leap=args.leap, + use_overintegration=args.overintegration, casename=casename, rst_filename=rst_filename, actx_class=actx_class) # vim: foldmethod=marker diff --git a/examples/poiseuille-mpi.py b/examples/poiseuille-mpi.py index fdbf119e9..4936be89b 100644 --- a/examples/poiseuille-mpi.py +++ b/examples/poiseuille-mpi.py @@ -83,8 +83,8 @@ def _get_box_mesh(dim, a, b, n, t=None): @mpi_entry_point def main(ctx_factory=cl.create_some_context, use_logmgr=True, - use_overintegration=False, lazy=False, - use_leap=False, use_profiling=False, casename=None, + use_overintegration=False, + use_leap=False, casename=None, rst_filename=None, actx_class=None): """Drive the example.""" if actx_class is None: @@ -106,19 +106,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control timestepper = rk4_step @@ -493,8 +483,8 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_leap=args.leap, use_profiling=args.profiling, - use_overintegration=args.overintegration, lazy=lazy, + main(use_logmgr=args.log, use_leap=args.leap, + use_overintegration=args.overintegration, casename=casename, rst_filename=rst_filename, actx_class=actx_class) # vim: foldmethod=marker diff --git a/examples/pulse-mpi.py b/examples/pulse-mpi.py index 5674ab57e..1948ff764 100644 --- a/examples/pulse-mpi.py +++ b/examples/pulse-mpi.py @@ -79,7 +79,7 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_overintegration=False, lazy=False, use_leap=False, use_profiling=False, + use_overintegration=False, use_leap=False, casename=None, rst_filename=None): """Drive the example.""" cl_ctx = ctx_factory() @@ -98,19 +98,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control current_step = 0 @@ -404,7 +394,7 @@ def my_rhs(t, state): rst_filename = args.restart_file main(actx_class, use_logmgr=args.log, use_overintegration=args.overintegration, - use_leap=args.leap, use_profiling=args.profiling, lazy=lazy, + use_leap=args.leap, casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/scalar-lump-mpi.py b/examples/scalar-lump-mpi.py index 6b0ee947c..7251a3c56 100644 --- a/examples/scalar-lump-mpi.py +++ b/examples/scalar-lump-mpi.py @@ -68,8 +68,8 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, - rst_filename=None, lazy=False): + use_leap=False, casename=None, + rst_filename=None): """Drive example.""" cl_ctx = ctx_factory() @@ -87,19 +87,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control current_step = 0 @@ -406,7 +396,7 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_leap=args.leap, lazy=lazy, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename) + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/sod-mpi.py b/examples/sod-mpi.py index a8de0e204..e9a44b5e8 100644 --- a/examples/sod-mpi.py +++ b/examples/sod-mpi.py @@ -67,7 +67,7 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, lazy=False, + use_leap=False, casename=None, rst_filename=None): """Drive the example.""" cl_ctx = ctx_factory() @@ -86,19 +86,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control if use_leap: @@ -394,7 +384,7 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_leap=args.leap, lazy=lazy, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename) + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/thermally-coupled-mpi.py b/examples/thermally-coupled-mpi.py index e70675cff..2a0e78de4 100644 --- a/examples/thermally-coupled-mpi.py +++ b/examples/thermally-coupled-mpi.py @@ -89,8 +89,8 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(ctx_factory=cl.create_some_context, use_logmgr=True, use_overintegration=False, - use_leap=False, use_profiling=False, casename=None, - rst_filename=None, actx_class=None, lazy=False): + use_leap=False, casename=None, + rst_filename=None, actx_class=None): """Drive the example.""" cl_ctx = ctx_factory() @@ -108,19 +108,9 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control current_step = 0 @@ -610,8 +600,8 @@ def my_rhs_and_gradients(t, state): rst_filename = args.restart_file main(use_logmgr=args.log, use_overintegration=args.overintegration, - use_leap=args.leap, use_profiling=args.profiling, + use_leap=args.leap, casename=casename, rst_filename=rst_filename, actx_class=actx_class, - lazy=args.lazy) + ) # vim: foldmethod=marker diff --git a/examples/vortex-mpi.py b/examples/vortex-mpi.py index 47b69d933..44f9582b1 100644 --- a/examples/vortex-mpi.py +++ b/examples/vortex-mpi.py @@ -69,8 +69,7 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, lazy=False, - rst_filename=None): + use_leap=False, casename=None, rst_filename=None): """Drive the example.""" cl_ctx = ctx_factory() @@ -88,19 +87,9 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control current_step = 0 @@ -419,7 +408,7 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_leap=args.leap, lazy=lazy, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename) + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker From e6e5843ba92fe8fc0041024b873abd837cd0e5fe Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Wed, 28 Jun 2023 15:14:58 -0500 Subject: [PATCH 04/17] linting --- examples/autoignition-mpi.py | 8 +++----- examples/combozzle-mpi.py | 8 +++----- examples/doublemach-mpi.py | 8 +++----- examples/doublemach_physical_av-mpi.py | 12 +++++------- examples/heat-source-mpi.py | 9 +++------ examples/hotplate-mpi.py | 8 +++----- examples/lump-mpi.py | 8 +++----- examples/mixture-mpi.py | 8 +++----- examples/multiple-volumes-mpi.py | 10 ++++------ examples/nsmix-mpi.py | 8 +++----- examples/poiseuille-local_dt-mpi.py | 8 +++----- examples/poiseuille-mpi.py | 8 +++----- examples/pulse-mpi.py | 8 +++----- examples/scalar-advdiff-mpi.py | 26 +++++++------------------- examples/scalar-lump-mpi.py | 8 +++----- examples/sod-mpi.py | 8 +++----- examples/thermally-coupled-mpi.py | 8 +++----- examples/vortex-mpi.py | 8 +++----- examples/wave-mpi.py | 12 ++++++------ examples/wave.py | 9 ++++++--- mirgecom/simutil.py | 15 ++++++++++----- 21 files changed, 83 insertions(+), 122 deletions(-) diff --git a/examples/autoignition-mpi.py b/examples/autoignition-mpi.py index b05f5783b..2d05679bd 100644 --- a/examples/autoignition-mpi.py +++ b/examples/autoignition-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL @@ -75,13 +74,11 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_leap=False, use_overintegration=False, casename=None, rst_filename=None, log_dependent=True, viscous_terms_on=False): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -97,7 +94,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + actx = initialize_actx(actx_class) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # Some discretization parameters diff --git a/examples/combozzle-mpi.py b/examples/combozzle-mpi.py index 8c7413356..9be3a6c69 100644 --- a/examples/combozzle-mpi.py +++ b/examples/combozzle-mpi.py @@ -27,7 +27,6 @@ import time import yaml import numpy as np -import pyopencl as cl from functools import partial from meshmode.array_context import PyOpenCLArrayContext @@ -160,14 +159,12 @@ def __call__(self, x_vec, *, time=0.0): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, +def main(use_logmgr=True, use_overintegration=False, casename=None, rst_filename=None, actx_class=PyOpenCLArrayContext, log_dependent=False, input_file=None, force_eval=True): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -600,7 +597,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, comm.Barrier() from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + actx = initialize_actx(actx_class) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) rst_path = "restart_data/" diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index 5b90a7671..5060e9065 100644 --- a/examples/doublemach-mpi.py +++ b/examples/doublemach-mpi.py @@ -26,7 +26,6 @@ import logging import numpy as np -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -116,15 +115,13 @@ def get_doublemach_mesh(): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, +def main(use_logmgr=True, use_leap=False, use_overintegration=False, casename=None, rst_filename=None, actx_class=None): """Drive the example.""" if actx_class is None: raise RuntimeError("Array context class missing.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -137,7 +134,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # Timestepping control diff --git a/examples/doublemach_physical_av-mpi.py b/examples/doublemach_physical_av-mpi.py index b04d2e269..392a97da2 100644 --- a/examples/doublemach_physical_av-mpi.py +++ b/examples/doublemach_physical_av-mpi.py @@ -26,7 +26,6 @@ import logging import numpy as np -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -120,15 +119,13 @@ def get_doublemach_mesh(): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, use_overintegration=False, - casename=None, rst_filename=None, actx_class=None, lazy=False): +def main(use_logmgr=True, + use_leap=False, use_overintegration=False, + casename=None, rst_filename=None, actx_class=None): """Drive the example.""" if actx_class is None: raise RuntimeError("Array context class missing.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -152,7 +149,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, filename=logname, mode="wo", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # Timestepping control diff --git a/examples/heat-source-mpi.py b/examples/heat-source-mpi.py index 9d4c68e99..52c4d9069 100644 --- a/examples/heat-source-mpi.py +++ b/examples/heat-source-mpi.py @@ -25,7 +25,6 @@ import numpy as np import numpy.linalg as la # noqa -import pyopencl as cl from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa import grudge.op as op @@ -48,12 +47,9 @@ @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_leap=False, casename=None, rst_filename=None): """Run the example.""" - cl_ctx = cl.create_some_context() - queue = cl.CommandQueue(cl_ctx) - from mpi4py import MPI comm = MPI.COMM_WORLD num_parts = comm.Get_size() @@ -62,7 +58,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename="heat-source.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) from meshmode.distributed import MPIMeshDistributor, get_partition_by_pymetis diff --git a/examples/hotplate-mpi.py b/examples/hotplate-mpi.py index 4c66a4eec..a50b05b2d 100644 --- a/examples/hotplate-mpi.py +++ b/examples/hotplate-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -81,15 +80,13 @@ def _get_box_mesh(dim, a, b, n, t=None): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, +def main(use_logmgr=True, use_leap=False, casename=None, rst_filename=None, actx_class=None): """Drive the example.""" if actx_class is None: raise RuntimeError("Array context class missing.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -105,7 +102,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class) + actx = initialize_actx(actx_class) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/lump-mpi.py b/examples/lump-mpi.py index 9a3f44544..a8bcd322d 100644 --- a/examples/lump-mpi.py +++ b/examples/lump-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -66,11 +65,9 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_leap=False, casename=None, rst_filename=None): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -86,7 +83,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/mixture-mpi.py b/examples/mixture-mpi.py index c48c4c0d9..bccf0d7b7 100644 --- a/examples/mixture-mpi.py +++ b/examples/mixture-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -72,12 +71,10 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_leap=False, casename=None, rst_filename=None, log_dependent=False): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -93,7 +90,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/multiple-volumes-mpi.py b/examples/multiple-volumes-mpi.py index 953c75dc8..6a620d946 100644 --- a/examples/multiple-volumes-mpi.py +++ b/examples/multiple-volumes-mpi.py @@ -33,7 +33,6 @@ from mirgecom.mpi import mpi_entry_point import numpy as np from functools import partial -import pyopencl as cl from pytools.obj_array import make_obj_array from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -82,12 +81,10 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_overintegration=False,use_leap=False, +def main(actx_class, use_logmgr=True, + use_overintegration=False, use_leap=False, casename=None, rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -103,7 +100,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/nsmix-mpi.py b/examples/nsmix-mpi.py index 17c0790dd..3be4f9274 100644 --- a/examples/nsmix-mpi.py +++ b/examples/nsmix-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from pytools.obj_array import make_obj_array @@ -78,7 +77,7 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, +def main(use_logmgr=True, use_leap=False, casename=None, rst_filename=None, actx_class=None, log_dependent=True, use_overintegration=False): @@ -86,8 +85,6 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, if actx_class is None: raise RuntimeError("Array context class missing.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -103,7 +100,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # Timestepping control diff --git a/examples/poiseuille-local_dt-mpi.py b/examples/poiseuille-local_dt-mpi.py index bf9ae0398..a07aa6f5e 100644 --- a/examples/poiseuille-local_dt-mpi.py +++ b/examples/poiseuille-local_dt-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from pytools.obj_array import make_obj_array from functools import partial @@ -72,7 +71,7 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, +def main(use_logmgr=True, use_overintegration=False, use_leap=False, casename=None, rst_filename=None, actx_class=None): @@ -80,8 +79,6 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, if actx_class is None: raise RuntimeError("Array context class missing.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -97,7 +94,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/poiseuille-mpi.py b/examples/poiseuille-mpi.py index 4936be89b..561a8dc12 100644 --- a/examples/poiseuille-mpi.py +++ b/examples/poiseuille-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from pytools.obj_array import make_obj_array from functools import partial @@ -82,7 +81,7 @@ def _get_box_mesh(dim, a, b, n, t=None): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, +def main(use_logmgr=True, use_overintegration=False, use_leap=False, casename=None, rst_filename=None, actx_class=None): @@ -90,8 +89,6 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, if actx_class is None: raise RuntimeError("Array context class missing.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -107,7 +104,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/pulse-mpi.py b/examples/pulse-mpi.py index 1948ff764..b324f72c7 100644 --- a/examples/pulse-mpi.py +++ b/examples/pulse-mpi.py @@ -28,7 +28,6 @@ from mirgecom.mpi import mpi_entry_point import numpy as np from functools import partial -import pyopencl as cl from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from grudge.shortcuts import make_visualizer @@ -78,12 +77,10 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_overintegration=False, use_leap=False, casename=None, rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -99,7 +96,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/scalar-advdiff-mpi.py b/examples/scalar-advdiff-mpi.py index 9b88de6e6..690862cee 100644 --- a/examples/scalar-advdiff-mpi.py +++ b/examples/scalar-advdiff-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from pytools.obj_array import make_obj_array @@ -70,12 +69,10 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, - use_leap=False, use_profiling=False, casename=None, - rst_filename=None, lazy=False): +def main(actx_class, use_logmgr=True, + use_leap=False, casename=None, + rst_filename=None): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -90,19 +87,10 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - if use_profiling: - queue = cl.CommandQueue( - cl_ctx, properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - from mirgecom.simutil import get_reasonable_memory_pool - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if lazy: - actx = actx_class(comm, queue, mpi_base_tag=12000, allocator=alloc) - else: - actx = actx_class(comm, queue, allocator=alloc, force_device_scalars=True) + from mirgecom.simutil import initialize_actx, actx_class_is_profiling + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) + use_profiling = actx_class_is_profiling(actx_class) # timestepping control current_step = 0 diff --git a/examples/scalar-lump-mpi.py b/examples/scalar-lump-mpi.py index 7251a3c56..410f4e7a6 100644 --- a/examples/scalar-lump-mpi.py +++ b/examples/scalar-lump-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from pytools.obj_array import make_obj_array @@ -67,12 +66,10 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_leap=False, casename=None, rst_filename=None): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -88,7 +85,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/sod-mpi.py b/examples/sod-mpi.py index e9a44b5e8..0d55cf904 100644 --- a/examples/sod-mpi.py +++ b/examples/sod-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np # noqa -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -66,12 +65,10 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_leap=False, casename=None, rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -87,7 +84,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/thermally-coupled-mpi.py b/examples/thermally-coupled-mpi.py index 2a0e78de4..8a0db584d 100644 --- a/examples/thermally-coupled-mpi.py +++ b/examples/thermally-coupled-mpi.py @@ -29,7 +29,6 @@ import numpy as np from functools import partial from pytools.obj_array import make_obj_array -import pyopencl as cl from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa from meshmode.discretization.connection import FACE_RESTR_ALL # noqa @@ -87,13 +86,11 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(ctx_factory=cl.create_some_context, use_logmgr=True, +def main(use_logmgr=True, use_overintegration=False, use_leap=False, casename=None, rst_filename=None, actx_class=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -109,7 +106,8 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/vortex-mpi.py b/examples/vortex-mpi.py index 44f9582b1..841e33417 100644 --- a/examples/vortex-mpi.py +++ b/examples/vortex-mpi.py @@ -25,7 +25,6 @@ """ import logging import numpy as np -import pyopencl as cl from functools import partial from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -68,11 +67,9 @@ class MyRuntimeError(RuntimeError): @mpi_entry_point -def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, +def main(actx_class, use_logmgr=True, use_leap=False, casename=None, rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -88,7 +85,8 @@ def main(actx_class, ctx_factory=cl.create_some_context, use_logmgr=True, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) # timestepping control diff --git a/examples/wave-mpi.py b/examples/wave-mpi.py index 4f71d8b16..d3a8a360b 100644 --- a/examples/wave-mpi.py +++ b/examples/wave-mpi.py @@ -26,7 +26,6 @@ import grudge.op as op import numpy as np import numpy.linalg as la # noqa -import pyopencl as cl from grudge.shortcuts import make_visualizer from logpyle import IntervalTimer, set_dt from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa @@ -66,9 +65,6 @@ def bump(actx, nodes, t=0): def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", restart_step=None, use_logmgr: bool = False) -> None: """Drive the example.""" - cl_ctx = cl.create_some_context() - queue = cl.CommandQueue(cl_ctx) - from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() @@ -78,7 +74,9 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", filename="wave-mpi.sqlite", mode="wu", mpi_comm=comm) from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, comm) + actx = initialize_actx(actx_class, comm) + queue = getattr(actx, "queue", None) + alloc = getattr(actx, "allocator", None) use_profiling = actx_class_is_profiling(actx_class) if restart_step is None: @@ -126,7 +124,9 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", from grudge.dt_utils import characteristic_lengthscales nodal_dt = characteristic_lengthscales(actx, dcoll) / wave_speed - dt = actx.to_numpy(current_cfl * op.nodal_min(dcoll, "vol", nodal_dt))[()] # type: ignore[index] + dt = actx.to_numpy(current_cfl + * op.nodal_min(dcoll, + "vol", nodal_dt))[()] # type: ignore[index] t_final = 1 diff --git a/examples/wave.py b/examples/wave.py index c152484cc..78807c592 100644 --- a/examples/wave.py +++ b/examples/wave.py @@ -63,7 +63,9 @@ def main(actx_class, use_logmgr: bool = False) -> None: filename="wave.sqlite", mode="wu") from mirgecom.simutil import actx_class_is_profiling, initialize_actx - actx, cl_ctx, queue, alloc = initialize_actx(actx_class, None) + actx = initialize_actx(actx_class, None) + queue = getattr(actx, "queue", None) + alloc = getattr(actx, "allocator", None) use_profiling = actx_class_is_profiling(actx_class) dim = 2 @@ -84,8 +86,9 @@ def main(actx_class, use_logmgr: bool = False) -> None: wave_speed = 1.0 from grudge.dt_utils import characteristic_lengthscales nodal_dt = characteristic_lengthscales(actx, dcoll) / wave_speed - dt = actx.to_numpy(current_cfl * op.nodal_min(dcoll, "vol", - nodal_dt))[()] # type: ignore[index] + dt = actx.to_numpy(current_cfl + * op.nodal_min(dcoll, "vol", + nodal_dt))[()] # type: ignore[index] print("%d elements" % mesh.nelements) diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index cdb063e0a..c6a62cac6 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -77,7 +77,7 @@ from meshmode.dof_array import DOFArray from mirgecom.viscous import get_viscous_timestep -from typing import List, Dict, Optional, Tuple, Any, TYPE_CHECKING, Type +from typing import List, Dict, Optional, TYPE_CHECKING, Type from grudge.discretization import DiscretizationCollection, PartID from grudge.dof_desc import DD_VOLUME_ALL from mirgecom.utils import normalize_boundaries @@ -1167,9 +1167,12 @@ def actx_class_is_profiling(actx_class) -> bool: return issubclass(actx_class, PyOpenCLProfilingArrayContext) -def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) -> Tuple[ArrayContext, cl.Context, cl.CommandQueue, cl.tools.AllocatorBase]: +def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) \ + -> ArrayContext: + """Initialize a new :class:`ArrayContext` based on *actx_class*.""" from arraycontext import PytatoPyOpenCLArrayContext, PyOpenCLArrayContext - from grudge.array_context import MPIPyOpenCLArrayContext, MPIPytatoPyOpenCLArrayContext + from grudge.array_context import (MPIPyOpenCLArrayContext, + MPIPytatoPyOpenCLArrayContext) cl_ctx = cl.create_some_context() if actx_class_is_profiling(actx_class): @@ -1184,7 +1187,9 @@ def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) -> T assert issubclass(actx_class, PytatoPyOpenCLArrayContext) if comm: assert issubclass(actx_class, MPIPytatoPyOpenCLArrayContext) - actx: ArrayContext = actx_class(mpi_communicator=comm, queue=queue, mpi_base_tag=12000, allocator=alloc) # type: ignore[call-arg] + actx: ArrayContext = actx_class(mpi_communicator=comm, queue=queue, + mpi_base_tag=12000, + allocator=alloc) # type: ignore[call-arg] else: assert not issubclass(actx_class, MPIPytatoPyOpenCLArrayContext) actx = actx_class(queue, allocator=alloc) @@ -1198,7 +1203,7 @@ def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) -> T assert not issubclass(actx_class, MPIPyOpenCLArrayContext) actx = actx_class(queue, allocator=alloc, force_device_scalars=True) - return actx, cl_ctx, queue, alloc + return actx def compare_files_vtu( From 3a3b5ca469060ccef4cadad2cf6abc9211cb2b9b Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Wed, 28 Jun 2023 15:29:38 -0500 Subject: [PATCH 05/17] pydocstyle --- mirgecom/simutil.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index c6a62cac6..9245607ce 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -1138,7 +1138,8 @@ def configurate(config_key, config_object=None, default_value=None): def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, - profiling: bool = False): + profiling: bool = False) -> Type[ArrayContext]: + """Return a :class:`ArrayContext` that satisfies the given constraints.""" if lazy and profiling: raise ValueError("Can't specify both lazy and profiling") @@ -1152,17 +1153,20 @@ def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = T return grudge_get_reasonable_actx_class(lazy=lazy, distributed=distributed) -def actx_class_is_lazy(actx_class) -> bool: +def actx_class_is_lazy(actx_class: Type[ArrayContext]) -> bool: + """Return True if *actx_class* is lazy.""" from arraycontext import PytatoPyOpenCLArrayContext return issubclass(actx_class, PytatoPyOpenCLArrayContext) -def actx_class_is_eager(actx_class) -> bool: +def actx_class_is_eager(actx_class: Type[ArrayContext]) -> bool: + """Return True if *actx_class* is eager.""" from arraycontext import PyOpenCLArrayContext return issubclass(actx_class, PyOpenCLArrayContext) -def actx_class_is_profiling(actx_class) -> bool: +def actx_class_is_profiling(actx_class: Type[ArrayContext]) -> bool: + """Return True if *actx_class* has profiling enabled.""" from mirgecom.profiling import PyOpenCLProfilingArrayContext return issubclass(actx_class, PyOpenCLProfilingArrayContext) From 9ffb079daab3b36cb93dd81b4a1d593289b9143b Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Wed, 28 Jun 2023 15:31:07 -0500 Subject: [PATCH 06/17] MPIPytatoArrayContext --- mirgecom/simutil.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index 9245607ce..f237f756e 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -1176,7 +1176,7 @@ def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) \ """Initialize a new :class:`ArrayContext` based on *actx_class*.""" from arraycontext import PytatoPyOpenCLArrayContext, PyOpenCLArrayContext from grudge.array_context import (MPIPyOpenCLArrayContext, - MPIPytatoPyOpenCLArrayContext) + MPIPytatoArrayContext) cl_ctx = cl.create_some_context() if actx_class_is_profiling(actx_class): @@ -1190,12 +1190,12 @@ def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) \ if actx_class_is_lazy(actx_class): assert issubclass(actx_class, PytatoPyOpenCLArrayContext) if comm: - assert issubclass(actx_class, MPIPytatoPyOpenCLArrayContext) + assert issubclass(actx_class, MPIPytatoArrayContext) actx: ArrayContext = actx_class(mpi_communicator=comm, queue=queue, mpi_base_tag=12000, allocator=alloc) # type: ignore[call-arg] else: - assert not issubclass(actx_class, MPIPytatoPyOpenCLArrayContext) + assert not issubclass(actx_class, MPIPytatoArrayContext) actx = actx_class(queue, allocator=alloc) else: assert issubclass(actx_class, PyOpenCLArrayContext) From 7801ca21ad49f5cc790d7e48a321e253218f9861 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Wed, 28 Jun 2023 16:19:23 -0500 Subject: [PATCH 07/17] add mirgecom/array_context.py, refactor --- doc/support/tools.rst | 1 + examples/autoignition-mpi.py | 6 +- examples/combozzle-mpi.py | 6 +- examples/doublemach-mpi.py | 4 +- examples/doublemach_physical_av-mpi.py | 4 +- examples/heat-source-mpi.py | 4 +- examples/hotplate-mpi.py | 6 +- examples/lump-mpi.py | 4 +- examples/mixture-mpi.py | 4 +- examples/multiple-volumes-mpi.py | 4 +- examples/nsmix-mpi.py | 4 +- examples/poiseuille-local_dt-mpi.py | 4 +- examples/poiseuille-mpi.py | 4 +- examples/pulse-mpi.py | 4 +- examples/scalar-advdiff-mpi.py | 4 +- examples/scalar-lump-mpi.py | 4 +- examples/sod-mpi.py | 4 +- examples/thermally-coupled-mpi.py | 4 +- examples/vortex-mpi.py | 4 +- examples/wave-mpi.py | 4 +- examples/wave.py | 4 +- mirgecom/array_context.py | 114 +++++++++++++++++++++++++ mirgecom/simutil.py | 82 +----------------- 23 files changed, 160 insertions(+), 123 deletions(-) create mode 100644 mirgecom/array_context.py diff --git a/doc/support/tools.rst b/doc/support/tools.rst index d29d63c2e..196fe56fd 100644 --- a/doc/support/tools.rst +++ b/doc/support/tools.rst @@ -3,3 +3,4 @@ Random Pile'o'Tools .. automodule:: mirgecom.simutil .. automodule:: mirgecom.utils +.. automodule:: mirgecom.array_context diff --git a/examples/autoignition-mpi.py b/examples/autoignition-mpi.py index 2d05679bd..6e8f8d0cd 100644 --- a/examples/autoignition-mpi.py +++ b/examples/autoignition-mpi.py @@ -93,8 +93,8 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx = initialize_actx(actx_class) + from mirgecom.array_context import initialize_actx, actx_class_is_profiling + actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -678,7 +678,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/combozzle-mpi.py b/examples/combozzle-mpi.py index 9be3a6c69..97dea1a5d 100644 --- a/examples/combozzle-mpi.py +++ b/examples/combozzle-mpi.py @@ -596,8 +596,8 @@ def main(use_logmgr=True, print(f"ACTX setup start: {time.ctime(time.time())}") comm.Barrier() - from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx = initialize_actx(actx_class) + from mirgecom.array_context import initialize_actx, actx_class_is_profiling + actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -1274,7 +1274,7 @@ def dummy_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index 5060e9065..6bcf2e045 100644 --- a/examples/doublemach-mpi.py +++ b/examples/doublemach-mpi.py @@ -133,7 +133,7 @@ def main(use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -449,7 +449,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/doublemach_physical_av-mpi.py b/examples/doublemach_physical_av-mpi.py index 392a97da2..56b903037 100644 --- a/examples/doublemach_physical_av-mpi.py +++ b/examples/doublemach_physical_av-mpi.py @@ -148,7 +148,7 @@ def main(use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=logname, mode="wo", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -720,7 +720,7 @@ def _my_rhs_phys_visc_div_av(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) diff --git a/examples/heat-source-mpi.py b/examples/heat-source-mpi.py index 52c4d9069..88b7f22b5 100644 --- a/examples/heat-source-mpi.py +++ b/examples/heat-source-mpi.py @@ -57,7 +57,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename="heat-source.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -194,7 +194,7 @@ def rhs(t, u): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/hotplate-mpi.py b/examples/hotplate-mpi.py index a50b05b2d..0314bdad8 100644 --- a/examples/hotplate-mpi.py +++ b/examples/hotplate-mpi.py @@ -101,8 +101,8 @@ def main(use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling - actx = initialize_actx(actx_class) + from mirgecom.array_context import initialize_actx, actx_class_is_profiling + actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -453,7 +453,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/lump-mpi.py b/examples/lump-mpi.py index a8bcd322d..b86fc4841 100644 --- a/examples/lump-mpi.py +++ b/examples/lump-mpi.py @@ -82,7 +82,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -372,7 +372,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/mixture-mpi.py b/examples/mixture-mpi.py index bccf0d7b7..6e98739e4 100644 --- a/examples/mixture-mpi.py +++ b/examples/mixture-mpi.py @@ -89,7 +89,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -452,7 +452,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/multiple-volumes-mpi.py b/examples/multiple-volumes-mpi.py index 6a620d946..d671560ec 100644 --- a/examples/multiple-volumes-mpi.py +++ b/examples/multiple-volumes-mpi.py @@ -99,7 +99,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -396,7 +396,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/nsmix-mpi.py b/examples/nsmix-mpi.py index 3be4f9274..651cba16d 100644 --- a/examples/nsmix-mpi.py +++ b/examples/nsmix-mpi.py @@ -99,7 +99,7 @@ def main(use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -631,7 +631,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/poiseuille-local_dt-mpi.py b/examples/poiseuille-local_dt-mpi.py index a07aa6f5e..55a9c4714 100644 --- a/examples/poiseuille-local_dt-mpi.py +++ b/examples/poiseuille-local_dt-mpi.py @@ -93,7 +93,7 @@ def main(use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -487,7 +487,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/poiseuille-mpi.py b/examples/poiseuille-mpi.py index 561a8dc12..5c2a278c3 100644 --- a/examples/poiseuille-mpi.py +++ b/examples/poiseuille-mpi.py @@ -103,7 +103,7 @@ def main(use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -471,7 +471,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/pulse-mpi.py b/examples/pulse-mpi.py index b324f72c7..fb0c09eca 100644 --- a/examples/pulse-mpi.py +++ b/examples/pulse-mpi.py @@ -95,7 +95,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -381,7 +381,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/scalar-advdiff-mpi.py b/examples/scalar-advdiff-mpi.py index 690862cee..3cbdd6901 100644 --- a/examples/scalar-advdiff-mpi.py +++ b/examples/scalar-advdiff-mpi.py @@ -87,7 +87,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -411,7 +411,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/scalar-lump-mpi.py b/examples/scalar-lump-mpi.py index 410f4e7a6..53bc07da3 100644 --- a/examples/scalar-lump-mpi.py +++ b/examples/scalar-lump-mpi.py @@ -84,7 +84,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -384,7 +384,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/sod-mpi.py b/examples/sod-mpi.py index 0d55cf904..bd0f83d16 100644 --- a/examples/sod-mpi.py +++ b/examples/sod-mpi.py @@ -83,7 +83,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -372,7 +372,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/thermally-coupled-mpi.py b/examples/thermally-coupled-mpi.py index 8a0db584d..05579661e 100644 --- a/examples/thermally-coupled-mpi.py +++ b/examples/thermally-coupled-mpi.py @@ -105,7 +105,7 @@ def main(use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -587,7 +587,7 @@ def my_rhs_and_gradients(t, state): if args.lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=args.lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/vortex-mpi.py b/examples/vortex-mpi.py index 841e33417..208f02bd5 100644 --- a/examples/vortex-mpi.py +++ b/examples/vortex-mpi.py @@ -84,7 +84,7 @@ def main(actx_class, use_logmgr=True, logmgr = initialize_logmgr(use_logmgr, filename=f"{casename}.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) use_profiling = actx_class_is_profiling(actx_class) @@ -396,7 +396,7 @@ def my_rhs(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) logging.basicConfig(format="%(message)s", level=logging.INFO) diff --git a/examples/wave-mpi.py b/examples/wave-mpi.py index d3a8a360b..5c6aecfae 100644 --- a/examples/wave-mpi.py +++ b/examples/wave-mpi.py @@ -73,7 +73,7 @@ def main(actx_class, snapshot_pattern="wave-mpi-{step:04d}-{rank:04d}.pkl", logmgr = initialize_logmgr(use_logmgr, filename="wave-mpi.sqlite", mode="wu", mpi_comm=comm) - from mirgecom.simutil import initialize_actx, actx_class_is_profiling + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, comm) queue = getattr(actx, "queue", None) alloc = getattr(actx, "allocator", None) @@ -252,7 +252,7 @@ def rhs(t, w): args = parser.parse_args() lazy = args.lazy - from mirgecom.simutil import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True, profiling=args.profiling) diff --git a/examples/wave.py b/examples/wave.py index 78807c592..8631b71af 100644 --- a/examples/wave.py +++ b/examples/wave.py @@ -62,7 +62,7 @@ def main(actx_class, use_logmgr: bool = False) -> None: logmgr = initialize_logmgr(use_logmgr, filename="wave.sqlite", mode="wu") - from mirgecom.simutil import actx_class_is_profiling, initialize_actx + from mirgecom.array_context import initialize_actx, actx_class_is_profiling actx = initialize_actx(actx_class, None) queue = getattr(actx, "queue", None) alloc = getattr(actx, "allocator", None) @@ -165,7 +165,7 @@ def rhs(t, w): help="enable lazy evaluation") args = parser.parse_args() - from grudge.array_context import get_reasonable_array_context_class + from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=args.lazy, distributed=False, profiling=args.profiling) diff --git a/mirgecom/array_context.py b/mirgecom/array_context.py new file mode 100644 index 000000000..be8c08f3b --- /dev/null +++ b/mirgecom/array_context.py @@ -0,0 +1,114 @@ +"""Provide some utilities for handling ArrayContexts. + +.. autofunction:: get_reasonable_array_context_class +.. autofunction:: actx_class_is_lazy +.. autofunction:: actx_class_is_eager +.. autofunction:: actx_class_is_profiling +.. autofunction:: initialize_actx +""" + +__copyright__ = """ +Copyright (C) 2023 University of Illinois Board of Trustees +""" + +__license__ = """ +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + +from typing import Type, Optional, TYPE_CHECKING + +import pyopencl as cl +from arraycontext import ArrayContext + +if TYPE_CHECKING: + from mpi4py.MPI import Comm + + +def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, + profiling: bool = False) -> Type[ArrayContext]: + """Return a :class:`ArrayContext` that satisfies the given constraints.""" + if lazy and profiling: + raise ValueError("Can't specify both lazy and profiling") + + if profiling: + from mirgecom.profiling import PyOpenCLProfilingArrayContext + return PyOpenCLProfilingArrayContext + + from grudge.array_context import \ + get_reasonable_array_context_class as grudge_get_reasonable_actx_class + + return grudge_get_reasonable_actx_class(lazy=lazy, distributed=distributed) + + +def actx_class_is_lazy(actx_class: Type[ArrayContext]) -> bool: + """Return True if *actx_class* is lazy.""" + from arraycontext import PytatoPyOpenCLArrayContext + return issubclass(actx_class, PytatoPyOpenCLArrayContext) + + +def actx_class_is_eager(actx_class: Type[ArrayContext]) -> bool: + """Return True if *actx_class* is eager.""" + from arraycontext import PyOpenCLArrayContext + return issubclass(actx_class, PyOpenCLArrayContext) + + +def actx_class_is_profiling(actx_class: Type[ArrayContext]) -> bool: + """Return True if *actx_class* has profiling enabled.""" + from mirgecom.profiling import PyOpenCLProfilingArrayContext + return issubclass(actx_class, PyOpenCLProfilingArrayContext) + + +def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) \ + -> ArrayContext: + """Initialize a new :class:`ArrayContext` based on *actx_class*.""" + from arraycontext import PyOpenCLArrayContext, PytatoPyOpenCLArrayContext + from grudge.array_context import (MPIPyOpenCLArrayContext, + MPIPytatoArrayContext) + + cl_ctx = cl.create_some_context() + if actx_class_is_profiling(actx_class): + queue = cl.CommandQueue(cl_ctx, + properties=cl.command_queue_properties.PROFILING_ENABLE) + else: + queue = cl.CommandQueue(cl_ctx) + + from mirgecom.simutil import get_reasonable_memory_pool + alloc = get_reasonable_memory_pool(cl_ctx, queue) + + if actx_class_is_lazy(actx_class): + assert issubclass(actx_class, PytatoPyOpenCLArrayContext) + if comm: + assert issubclass(actx_class, MPIPytatoArrayContext) + actx: ArrayContext = actx_class(mpi_communicator=comm, queue=queue, + mpi_base_tag=12000, + allocator=alloc) # type: ignore[call-arg] + else: + assert not issubclass(actx_class, MPIPytatoArrayContext) + actx = actx_class(queue, allocator=alloc) + else: + assert issubclass(actx_class, PyOpenCLArrayContext) + if comm: + assert issubclass(actx_class, MPIPyOpenCLArrayContext) + actx = actx_class(mpi_communicator=comm, queue=queue, allocator=alloc, + force_device_scalars=True) # type: ignore[call-arg] + else: + assert not issubclass(actx_class, MPIPyOpenCLArrayContext) + actx = actx_class(queue, allocator=alloc, force_device_scalars=True) + + return actx diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index f237f756e..ec6e29660 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -30,11 +30,6 @@ ---------------------------- .. autofunction:: configurate -.. autofunction:: get_reasonable_array_context_class -.. autofunction:: actx_class_is_lazy -.. autofunction:: actx_class_is_eager -.. autofunction:: actx_class_is_profiling -.. autofunction:: initialize_actx File comparison utilities ------------------------- @@ -73,11 +68,11 @@ import grudge.op as op -from arraycontext import map_array_container, flatten, ArrayContext +from arraycontext import map_array_container, flatten from meshmode.dof_array import DOFArray from mirgecom.viscous import get_viscous_timestep -from typing import List, Dict, Optional, TYPE_CHECKING, Type +from typing import List, Dict, Optional, TYPE_CHECKING from grudge.discretization import DiscretizationCollection, PartID from grudge.dof_desc import DD_VOLUME_ALL from mirgecom.utils import normalize_boundaries @@ -1137,79 +1132,6 @@ def configurate(config_key, config_object=None, default_value=None): return default_value -def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, - profiling: bool = False) -> Type[ArrayContext]: - """Return a :class:`ArrayContext` that satisfies the given constraints.""" - if lazy and profiling: - raise ValueError("Can't specify both lazy and profiling") - - if profiling: - from mirgecom.profiling import PyOpenCLProfilingArrayContext - return PyOpenCLProfilingArrayContext - - from grudge.array_context import (get_reasonable_actx_class as - grudge_get_reasonable_actx_class) - - return grudge_get_reasonable_actx_class(lazy=lazy, distributed=distributed) - - -def actx_class_is_lazy(actx_class: Type[ArrayContext]) -> bool: - """Return True if *actx_class* is lazy.""" - from arraycontext import PytatoPyOpenCLArrayContext - return issubclass(actx_class, PytatoPyOpenCLArrayContext) - - -def actx_class_is_eager(actx_class: Type[ArrayContext]) -> bool: - """Return True if *actx_class* is eager.""" - from arraycontext import PyOpenCLArrayContext - return issubclass(actx_class, PyOpenCLArrayContext) - - -def actx_class_is_profiling(actx_class: Type[ArrayContext]) -> bool: - """Return True if *actx_class* has profiling enabled.""" - from mirgecom.profiling import PyOpenCLProfilingArrayContext - return issubclass(actx_class, PyOpenCLProfilingArrayContext) - - -def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) \ - -> ArrayContext: - """Initialize a new :class:`ArrayContext` based on *actx_class*.""" - from arraycontext import PytatoPyOpenCLArrayContext, PyOpenCLArrayContext - from grudge.array_context import (MPIPyOpenCLArrayContext, - MPIPytatoArrayContext) - - cl_ctx = cl.create_some_context() - if actx_class_is_profiling(actx_class): - queue = cl.CommandQueue(cl_ctx, - properties=cl.command_queue_properties.PROFILING_ENABLE) - else: - queue = cl.CommandQueue(cl_ctx) - - alloc = get_reasonable_memory_pool(cl_ctx, queue) - - if actx_class_is_lazy(actx_class): - assert issubclass(actx_class, PytatoPyOpenCLArrayContext) - if comm: - assert issubclass(actx_class, MPIPytatoArrayContext) - actx: ArrayContext = actx_class(mpi_communicator=comm, queue=queue, - mpi_base_tag=12000, - allocator=alloc) # type: ignore[call-arg] - else: - assert not issubclass(actx_class, MPIPytatoArrayContext) - actx = actx_class(queue, allocator=alloc) - else: - assert issubclass(actx_class, PyOpenCLArrayContext) - if comm: - assert issubclass(actx_class, MPIPyOpenCLArrayContext) - actx = actx_class(mpi_communicator=comm, queue=queue, allocator=alloc, - force_device_scalars=True) # type: ignore[call-arg] - else: - assert not issubclass(actx_class, MPIPyOpenCLArrayContext) - actx = actx_class(queue, allocator=alloc, force_device_scalars=True) - - return actx - - def compare_files_vtu( first_file: str, second_file: str, From 60b99831af2280db41bc0d99ee4be06c86663e99 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Wed, 28 Jun 2023 17:46:38 -0500 Subject: [PATCH 08/17] more fixes --- examples/autoignition-mpi.py | 4 ++-- examples/combozzle-mpi.py | 5 +++-- examples/doublemach-mpi.py | 3 ++- examples/doublemach_physical_av-mpi.py | 7 ++++--- examples/heat-source-mpi.py | 3 ++- examples/hotplate-mpi.py | 3 ++- examples/lump-mpi.py | 3 ++- examples/mixture-mpi.py | 3 ++- examples/multiple-volumes-mpi.py | 3 ++- examples/nsmix-mpi.py | 3 ++- examples/poiseuille-local_dt-mpi.py | 3 ++- examples/poiseuille-mpi.py | 3 ++- examples/pulse-mpi.py | 3 ++- examples/scalar-advdiff-mpi.py | 7 ++++--- examples/sod-mpi.py | 3 ++- examples/thermally-coupled-mpi.py | 3 ++- examples/vortex-mpi.py | 3 ++- 17 files changed, 39 insertions(+), 23 deletions(-) diff --git a/examples/autoignition-mpi.py b/examples/autoignition-mpi.py index 6e8f8d0cd..73327e19d 100644 --- a/examples/autoignition-mpi.py +++ b/examples/autoignition-mpi.py @@ -689,8 +689,8 @@ def my_rhs(t, state): rst_filename = args.restart_file main(actx_class, use_logmgr=args.log, use_leap=args.leap, - use_overintegration=args.overintegration, use_profiling=args.profiling, - lazy=lazy, casename=casename, rst_filename=rst_filename, + use_overintegration=args.overintegration, + casename=casename, rst_filename=rst_filename, log_dependent=log_dependent, viscous_terms_on=args.navierstokes) # vim: foldmethod=marker diff --git a/examples/combozzle-mpi.py b/examples/combozzle-mpi.py index 97dea1a5d..2aedd8730 100644 --- a/examples/combozzle-mpi.py +++ b/examples/combozzle-mpi.py @@ -1275,7 +1275,8 @@ def dummy_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: @@ -1293,7 +1294,7 @@ def dummy_rhs(t, state): print(f"Calling main: {time.ctime(time.time())}") - main(use_logmgr=args.log, use_leap=args.leap, input_file=input_file, + main(use_logmgr=args.log, input_file=input_file, use_overintegration=args.overintegration, casename=casename, rst_filename=rst_filename, actx_class=actx_class, log_dependent=log_dependent, force_eval=force_eval) diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index 6bcf2e045..e7454a167 100644 --- a/examples/doublemach-mpi.py +++ b/examples/doublemach-mpi.py @@ -450,7 +450,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True, + profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/doublemach_physical_av-mpi.py b/examples/doublemach_physical_av-mpi.py index 56b903037..8c462ed23 100644 --- a/examples/doublemach_physical_av-mpi.py +++ b/examples/doublemach_physical_av-mpi.py @@ -722,7 +722,8 @@ def _my_rhs_phys_visc_div_av(t, state): from mirgecom.array_context import get_reasonable_array_context_class actx_class = get_reasonable_array_context_class(lazy=lazy, - distributed=True) + distributed=True, + profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: @@ -731,8 +732,8 @@ def _my_rhs_phys_visc_div_av(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_leap=args.leap, use_profiling=args.profiling, - use_overintegration=args.overintegration, lazy=lazy, + main(use_logmgr=args.log, use_leap=args.leap, + use_overintegration=args.overintegration, casename=casename, rst_filename=rst_filename, actx_class=actx_class) # vim: foldmethod=marker diff --git a/examples/heat-source-mpi.py b/examples/heat-source-mpi.py index 88b7f22b5..18ecf36c6 100644 --- a/examples/heat-source-mpi.py +++ b/examples/heat-source-mpi.py @@ -195,7 +195,8 @@ def rhs(t, u): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/hotplate-mpi.py b/examples/hotplate-mpi.py index 0314bdad8..f9cd042b2 100644 --- a/examples/hotplate-mpi.py +++ b/examples/hotplate-mpi.py @@ -454,7 +454,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/lump-mpi.py b/examples/lump-mpi.py index b86fc4841..6129a6e32 100644 --- a/examples/lump-mpi.py +++ b/examples/lump-mpi.py @@ -373,7 +373,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/mixture-mpi.py b/examples/mixture-mpi.py index 6e98739e4..ea88431b4 100644 --- a/examples/mixture-mpi.py +++ b/examples/mixture-mpi.py @@ -453,7 +453,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/multiple-volumes-mpi.py b/examples/multiple-volumes-mpi.py index d671560ec..55648ba3c 100644 --- a/examples/multiple-volumes-mpi.py +++ b/examples/multiple-volumes-mpi.py @@ -397,7 +397,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/nsmix-mpi.py b/examples/nsmix-mpi.py index 651cba16d..0a61030ff 100644 --- a/examples/nsmix-mpi.py +++ b/examples/nsmix-mpi.py @@ -632,7 +632,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/poiseuille-local_dt-mpi.py b/examples/poiseuille-local_dt-mpi.py index 55a9c4714..2159093a4 100644 --- a/examples/poiseuille-local_dt-mpi.py +++ b/examples/poiseuille-local_dt-mpi.py @@ -488,7 +488,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/poiseuille-mpi.py b/examples/poiseuille-mpi.py index 5c2a278c3..690dbe2ac 100644 --- a/examples/poiseuille-mpi.py +++ b/examples/poiseuille-mpi.py @@ -472,7 +472,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/pulse-mpi.py b/examples/pulse-mpi.py index fb0c09eca..15b77ad1d 100644 --- a/examples/pulse-mpi.py +++ b/examples/pulse-mpi.py @@ -382,7 +382,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/scalar-advdiff-mpi.py b/examples/scalar-advdiff-mpi.py index 3cbdd6901..abf3db45f 100644 --- a/examples/scalar-advdiff-mpi.py +++ b/examples/scalar-advdiff-mpi.py @@ -412,7 +412,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True, + profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: @@ -421,7 +422,7 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_leap=args.leap, lazy=lazy, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename) + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/sod-mpi.py b/examples/sod-mpi.py index bd0f83d16..acebeaea8 100644 --- a/examples/sod-mpi.py +++ b/examples/sod-mpi.py @@ -373,7 +373,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/thermally-coupled-mpi.py b/examples/thermally-coupled-mpi.py index 05579661e..f9d2cf2c5 100644 --- a/examples/thermally-coupled-mpi.py +++ b/examples/thermally-coupled-mpi.py @@ -588,7 +588,8 @@ def my_rhs_and_gradients(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=args.lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=args.lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/vortex-mpi.py b/examples/vortex-mpi.py index 208f02bd5..3bbc69a02 100644 --- a/examples/vortex-mpi.py +++ b/examples/vortex-mpi.py @@ -397,7 +397,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: From 825478d94898e6add6f029bc3540e0d74e03b557 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 29 Jun 2023 10:56:18 -0500 Subject: [PATCH 09/17] fix doc issues --- doc/conf.py | 3 +++ mirgecom/array_context.py | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 4665159d9..7b57c7ff8 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -97,3 +97,6 @@ nitpick_ignore_regex = [ ("py:class", r".*BoundaryDomainTag.*") ] + +import sys +sys._BUILDING_SPHINX_DOCS = True diff --git a/mirgecom/array_context.py b/mirgecom/array_context.py index be8c08f3b..84bc80a0a 100644 --- a/mirgecom/array_context.py +++ b/mirgecom/array_context.py @@ -35,14 +35,15 @@ import pyopencl as cl from arraycontext import ArrayContext +import sys -if TYPE_CHECKING: +if TYPE_CHECKING or getattr(sys, "_BUILDING_SPHINX_DOCS", False): from mpi4py.MPI import Comm def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, profiling: bool = False) -> Type[ArrayContext]: - """Return a :class:`ArrayContext` that satisfies the given constraints.""" + """Return a :class:`~arraycontext.ArrayContext` with the given constraints.""" if lazy and profiling: raise ValueError("Can't specify both lazy and profiling") @@ -76,7 +77,7 @@ def actx_class_is_profiling(actx_class: Type[ArrayContext]) -> bool: def initialize_actx(actx_class: Type[ArrayContext], comm: Optional["Comm"]) \ -> ArrayContext: - """Initialize a new :class:`ArrayContext` based on *actx_class*.""" + """Initialize a new :class:`~arraycontext.ArrayContext` based on *actx_class*.""" from arraycontext import PyOpenCLArrayContext, PytatoPyOpenCLArrayContext from grudge.array_context import (MPIPyOpenCLArrayContext, MPIPytatoArrayContext) From 8508097eb1ba9f847dc5e1388218a7417f6a8f06 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 29 Jun 2023 12:32:00 -0500 Subject: [PATCH 10/17] fix flake8 --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 7b57c7ff8..362edebee 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,4 +1,5 @@ # -- Project information ----------------------------------------------------- +import sys project = "mirgecom" copyright = ("2020, University of Illinois Board of Trustees") @@ -98,5 +99,4 @@ ("py:class", r".*BoundaryDomainTag.*") ] -import sys sys._BUILDING_SPHINX_DOCS = True From 03bb20ef110929fda66c2e7bf15f63aa69c6ebc9 Mon Sep 17 00:00:00 2001 From: Mike Campbell Date: Thu, 29 Jun 2023 12:34:14 -0500 Subject: [PATCH 11/17] Disable no member on pylint for MPI Comm. --- mirgecom/array_context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mirgecom/array_context.py b/mirgecom/array_context.py index 84bc80a0a..fa6d0a171 100644 --- a/mirgecom/array_context.py +++ b/mirgecom/array_context.py @@ -38,7 +38,7 @@ import sys if TYPE_CHECKING or getattr(sys, "_BUILDING_SPHINX_DOCS", False): - from mpi4py.MPI import Comm + from mpi4py.MPI import Comm # pylint: disable=no-member def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, From 016cb105934a235ea44382e2a68a29a0f4cca418 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 29 Jun 2023 13:32:03 -0500 Subject: [PATCH 12/17] fix pylint --- mirgecom/array_context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mirgecom/array_context.py b/mirgecom/array_context.py index fa6d0a171..f3cc3900a 100644 --- a/mirgecom/array_context.py +++ b/mirgecom/array_context.py @@ -38,7 +38,7 @@ import sys if TYPE_CHECKING or getattr(sys, "_BUILDING_SPHINX_DOCS", False): - from mpi4py.MPI import Comm # pylint: disable=no-member + from mpi4py.MPI import Comm # pylint: disable=no-name-in-module def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, From 5e99342f570d406b3739caa531ebd2b9019be498 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 29 Jun 2023 14:52:37 -0500 Subject: [PATCH 13/17] fix doc build --- mirgecom/simutil.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index ec6e29660..8e95474df 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -63,24 +63,24 @@ THE SOFTWARE. """ import logging -import numpy as np +import sys from functools import partial +from typing import TYPE_CHECKING, Dict, List, Optional import grudge.op as op - -from arraycontext import map_array_container, flatten -from meshmode.dof_array import DOFArray -from mirgecom.viscous import get_viscous_timestep - -from typing import List, Dict, Optional, TYPE_CHECKING +import numpy as np +import pyopencl as cl +from arraycontext import flatten, map_array_container from grudge.discretization import DiscretizationCollection, PartID from grudge.dof_desc import DD_VOLUME_ALL +from meshmode.dof_array import DOFArray + from mirgecom.utils import normalize_boundaries -import pyopencl as cl +from mirgecom.viscous import get_viscous_timestep logger = logging.getLogger(__name__) -if TYPE_CHECKING: +if TYPE_CHECKING or getattr(sys, "_BUILDING_SPHINX_DOCS", False): from mpi4py.MPI import Comm @@ -245,7 +245,8 @@ def write_visfile(dcoll, io_fields, visualizer, vizname, collection. This will stop working in Fall 2022.) """ from contextlib import nullcontext - from mirgecom.io import make_rank_fname, make_par_fname + + from mirgecom.io import make_par_fname, make_rank_fname if comm is None: # None is OK for serial writes! comm = dcoll.mpi_communicator @@ -903,7 +904,8 @@ def partition_generator_func(mesh, tag_to_elements, num_ranks): part_id_to_part_index = { part_id: part_index for part_index, part_id in enumerate(part_id_to_elements.keys())} - from meshmode.mesh.processing import _compute_global_elem_to_part_elem + from meshmode.mesh.processing import \ + _compute_global_elem_to_part_elem global_elem_to_part_elem = _compute_global_elem_to_part_elem( mesh.nelements, part_id_to_elements, part_id_to_part_index, mesh.element_id_dtype) @@ -982,7 +984,7 @@ def extract_volumes(mesh, tag_to_elements, selected_tags, boundary_tag): # partition_mesh creates a partition boundary for "_out"; replace with a # normal boundary new_facial_adjacency_groups = [] - from meshmode.mesh import InterPartAdjacencyGroup, BoundaryAdjacencyGroup + from meshmode.mesh import BoundaryAdjacencyGroup, InterPartAdjacencyGroup for grp_list in in_mesh.facial_adjacency_groups: new_grp_list = [] for fagrp in grp_list: @@ -1041,8 +1043,8 @@ def boundary_report(dcoll, boundaries, outfile_name, *, dd=DD_VOLUME_ALL, nnodes = sum([grp.ndofs for grp in boundary_discr.groups]) local_report.write(f"{bdtag}: {nnodes}\n") - from meshmode.mesh import BTAG_PARTITION from meshmode.distributed import get_connected_parts + from meshmode.mesh import BTAG_PARTITION connected_part_ids = get_connected_parts(dcoll.discr_from_dd(dd).mesh) local_report.write(f"num_nbr_parts: {len(connected_part_ids)}\n") local_report.write(f"connected_part_ids: {connected_part_ids}\n") @@ -1086,8 +1088,8 @@ def get_reasonable_memory_pool(ctx: cl.Context, queue: cl.CommandQueue, By default, it prefers SVM allocations over CL buffers, and memory pools over direct allocations. """ - from pyopencl.characterize import has_coarse_grain_buffer_svm import pyopencl.tools as cl_tools + from pyopencl.characterize import has_coarse_grain_buffer_svm if force_buffer and force_non_pool: logger.info(f"Using non-pooled CL buffer allocations on {queue.device}.") @@ -1161,9 +1163,10 @@ def compare_files_vtu( False: If it fails the files contain data outside the given tolerance. """ - import vtk import xml.etree.ElementTree as Et + import vtk + # read files: if file_type == "vtu": reader1 = vtk.vtkXMLUnstructuredGridReader() # pylint: disable=no-member From 176459fc8b5860f4e2a13c54681a7e2e2f452618 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Thu, 29 Jun 2023 15:28:47 -0500 Subject: [PATCH 14/17] enforce specifying all args to get_reasonable_array_context_class --- examples/autoignition-mpi.py | 3 ++- examples/scalar-lump-mpi.py | 3 ++- mirgecom/array_context.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/autoignition-mpi.py b/examples/autoignition-mpi.py index 73327e19d..48963d3a7 100644 --- a/examples/autoignition-mpi.py +++ b/examples/autoignition-mpi.py @@ -679,7 +679,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/examples/scalar-lump-mpi.py b/examples/scalar-lump-mpi.py index 53bc07da3..8c14feb9c 100644 --- a/examples/scalar-lump-mpi.py +++ b/examples/scalar-lump-mpi.py @@ -385,7 +385,8 @@ def my_rhs(t, state): raise ValueError("Can't use lazy and profiling together.") from mirgecom.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + actx_class = get_reasonable_array_context_class( + lazy=lazy, distributed=True, profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: diff --git a/mirgecom/array_context.py b/mirgecom/array_context.py index f3cc3900a..dbed70e12 100644 --- a/mirgecom/array_context.py +++ b/mirgecom/array_context.py @@ -41,8 +41,8 @@ from mpi4py.MPI import Comm # pylint: disable=no-name-in-module -def get_reasonable_array_context_class(lazy: bool = False, distributed: bool = True, - profiling: bool = False) -> Type[ArrayContext]: +def get_reasonable_array_context_class(*, lazy: bool, distributed: bool, + profiling: bool) -> Type[ArrayContext]: """Return a :class:`~arraycontext.ArrayContext` with the given constraints.""" if lazy and profiling: raise ValueError("Can't specify both lazy and profiling") From e4a14287367e1792af6296eabf2aac4812727327 Mon Sep 17 00:00:00 2001 From: Mike Campbell Date: Thu, 29 Jun 2023 16:05:56 -0500 Subject: [PATCH 15/17] Correct placement of pylint disable? --- mirgecom/array_context.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mirgecom/array_context.py b/mirgecom/array_context.py index dbed70e12..5ab71a186 100644 --- a/mirgecom/array_context.py +++ b/mirgecom/array_context.py @@ -38,7 +38,8 @@ import sys if TYPE_CHECKING or getattr(sys, "_BUILDING_SPHINX_DOCS", False): - from mpi4py.MPI import Comm # pylint: disable=no-name-in-module + # pylint: disable=no-name-in-module + from mpi4py.MPI import Comm def get_reasonable_array_context_class(*, lazy: bool, distributed: bool, From 36bb89898873437addb6c3f8fb0f48ce34300fc6 Mon Sep 17 00:00:00 2001 From: Mike Campbell Date: Thu, 29 Jun 2023 16:27:08 -0500 Subject: [PATCH 16/17] Disable pylint no-name-in-module for MPI.Comm --- mirgecom/simutil.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mirgecom/simutil.py b/mirgecom/simutil.py index 8e95474df..62c927a46 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -81,6 +81,7 @@ logger = logging.getLogger(__name__) if TYPE_CHECKING or getattr(sys, "_BUILDING_SPHINX_DOCS", False): + # pylint: disable=no-name-in-module from mpi4py.MPI import Comm From 661845a97b11af02e3337161a6f931259b90a38e Mon Sep 17 00:00:00 2001 From: Mike Campbell Date: Thu, 29 Jun 2023 17:47:35 -0500 Subject: [PATCH 17/17] Correct merge error --- examples/doublemach-mpi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index 9fa4174cc..c17ede4d4 100644 --- a/examples/doublemach-mpi.py +++ b/examples/doublemach-mpi.py @@ -469,8 +469,8 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_leap=args.leap, use_esdg=False, - use_overintegration=args.overintegration or args.esdg, lazy=lazy, + main(use_logmgr=args.log, use_leap=args.leap, use_esdg=args.esdg, + use_overintegration=args.overintegration or args.esdg, casename=casename, rst_filename=rst_filename, actx_class=actx_class) # vim: foldmethod=marker