diff --git a/doc/conf.py b/doc/conf.py index 4665159d9..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") @@ -97,3 +98,5 @@ nitpick_ignore_regex = [ ("py:class", r".*BoundaryDomainTag.*") ] + +sys._BUILDING_SPHINX_DOCS = True 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 bdfe788a3..4eda62514 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, - use_leap=False, use_overintegration=False, use_profiling=False, - casename=None, lazy=False, rst_filename=None, log_dependent=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, use_esdg=False): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -96,19 +93,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.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) # Some discretization parameters dim = 2 @@ -698,8 +686,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -710,8 +699,7 @@ def my_rhs(t, state): main(actx_class, use_logmgr=args.log, use_leap=args.leap, use_overintegration=args.overintegration or args.esdg, - use_profiling=args.profiling, use_esdg=args.esdg, - lazy=lazy, casename=casename, rst_filename=rst_filename, + casename=casename, rst_filename=rst_filename, use_esdg=args.esdg, 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 0dcde1bd1..ebbb59489 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 @@ -161,15 +160,12 @@ 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, +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, use_esdg=False): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -601,19 +597,10 @@ 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.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) rst_path = "restart_data/" rst_pattern = ( @@ -1295,8 +1282,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -1316,7 +1304,6 @@ def dummy_rhs(t, state): main(use_logmgr=args.log, use_leap=args.leap, input_file=input_file, use_overintegration=args.overintegration or args.esdg, - use_profiling=args.profiling, lazy=lazy, casename=casename, rst_filename=rst_filename, actx_class=actx_class, log_dependent=log_dependent, force_eval=force_eval, use_esdg=args.esdg) diff --git a/examples/doublemach-mpi.py b/examples/doublemach-mpi.py index 618a35a79..c17ede4d4 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,16 +115,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, - use_esdg=False): +def main(use_logmgr=True, use_esdg=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.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -137,19 +133,10 @@ 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.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) # Timestepping control current_step = 0 @@ -471,8 +458,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -481,9 +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_profiling=args.profiling, - use_overintegration=args.overintegration or args.esdg, lazy=lazy, - casename=casename, rst_filename=rst_filename, actx_class=actx_class, - use_esdg=args.esdg) + 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 diff --git a/examples/doublemach_physical_av-mpi.py b/examples/doublemach_physical_av-mpi.py index 096c20042..ce5af45f8 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,16 +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, - use_esdg=False): +def main(use_logmgr=True, use_esdg=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.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -152,19 +148,10 @@ 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.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) # Timestepping control current_step = 0 @@ -746,9 +733,10 @@ 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) + distributed=True, + profiling=args.profiling) logging.basicConfig(format="%(message)s", level=logging.INFO) if args.casename: @@ -757,9 +745,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, + main(use_logmgr=args.log, use_leap=args.leap, use_esdg=args.esdg, use_overintegration=args.overintegration or args.esdg, - use_esdg=args.esdg, lazy=lazy, 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 3daaefe49..6c28c36dc 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,13 +47,10 @@ @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_overintegration=False): +def main(actx_class, use_logmgr=True, use_esdg=False, + use_overintegration=False, + 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,19 +58,10 @@ 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.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) from meshmode.distributed import MPIMeshDistributor, get_partition_by_pymetis mesh_dist = MPIMeshDistributor(comm) @@ -203,6 +190,8 @@ def rhs(t, u): help="switch to a lazy computation mode") parser.add_argument("--profiling", action="store_true", help="turn on detailed performance profiling") + parser.add_argument("--overintegration", action="store_true", + help="turn on overintegration.") parser.add_argument("--log", action="store_true", default=True, help="turn on logging") parser.add_argument("--leap", action="store_true", @@ -215,8 +204,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -225,7 +215,8 @@ 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, + use_overintegration=args.overintegration, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/hotplate-mpi.py b/examples/hotplate-mpi.py index c54752f72..bb3106dd3 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,16 +80,14 @@ 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_esdg=False, use_overintegration=False): +def main(use_logmgr=True, use_esdg=False, + use_leap=False, casename=None, + use_overintegration=False, + 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,19 +102,10 @@ 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.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) # timestepping control timestepper = rk4_step @@ -485,8 +473,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -495,9 +484,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, - lazy=lazy, use_overintegration=args.overintegration or args.esdg, + use_overintegration=args.overintegration or args.esdg, use_esdg=args.esdg) # vim: foldmethod=marker diff --git a/examples/lump-mpi.py b/examples/lump-mpi.py index 2f98f9aa5..dbbb6a167 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 grudge.dof_desc import DISCR_TAG_QUAD @@ -67,12 +66,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, lazy=False, - rst_filename=None, use_esdg=False, use_overintegration=False): +def main(actx_class, use_logmgr=True, use_esdg=False, + use_overintegration=False, + use_leap=False, casename=None, rst_filename=None): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -87,19 +84,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.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) # timestepping control if use_leap: @@ -409,8 +397,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -419,8 +408,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, use_esdg=args.esdg, use_overintegration=args.esdg or args.overintegration) # vim: foldmethod=marker diff --git a/examples/mixture-mpi.py b/examples/mixture-mpi.py index 738fb5c02..40ff08dff 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, - use_leap=False, use_profiling=False, casename=None, rst_filename=None, - log_dependent=False, lazy=False, use_esdg=False, use_overintegration=False): +def main(actx_class, use_logmgr=True, use_esdg=False, + use_leap=False, casename=None, rst_filename=None, + log_dependent=False, use_overintegration=False): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -92,19 +89,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.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) # timestepping control if use_leap: @@ -474,8 +462,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -485,9 +474,9 @@ 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, - log_dependent=log_dependent, use_esdg=args.esdg, - use_overintegration=args.overintegration or args.esdg) + main(actx_class, use_logmgr=args.log, use_leap=args.leap, + casename=casename, rst_filename=rst_filename, + use_overintegration=args.overintegration or args.esdg, + use_esdg=args.esdg, log_dependent=log_dependent) # vim: foldmethod=marker diff --git a/examples/multiple-volumes-mpi.py b/examples/multiple-volumes-mpi.py index adbf68e2e..817975d86 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, lazy=False, use_leap=False, use_profiling=False, - casename=None, rst_filename=None, use_esdg=False): +def main(actx_class, use_logmgr=True, use_esdg=False, + use_overintegration=False, use_leap=False, + casename=None, rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -102,19 +99,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.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) # timestepping control current_step = 0 @@ -418,8 +406,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -428,9 +417,9 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, use_esdg=args.esdg, + main(actx_class, use_logmgr=args.log, use_overintegration=args.overintegration, + use_leap=args.leap, use_esdg=args.esdg, use_overintegration=args.overintegration or args.esdg, - use_leap=args.leap, use_profiling=args.profiling, lazy=lazy, casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/nsmix-mpi.py b/examples/nsmix-mpi.py index 18d388751..c9d582c2f 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,17 +77,14 @@ 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, - log_dependent=True, use_overintegration=False, - use_esdg=False): +def main(use_logmgr=True, use_esdg=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: raise RuntimeError("Array context class missing.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -103,19 +99,10 @@ 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.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) # Timestepping control # This example runs only 3 steps by default (to keep CI ~short) @@ -652,8 +639,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -662,9 +650,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, use_esdg=args.esdg, + log_dependent=log_dependent, use_esdg=args.esdg, use_overintegration=args.overintegration or args.esdg) # vim: foldmethod=marker diff --git a/examples/poiseuille-local_dt-mpi.py b/examples/poiseuille-local_dt-mpi.py index 3adadb407..8bc70ce4f 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,16 +71,14 @@ 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, - rst_filename=None, actx_class=None, use_esdg=False): +def main(use_logmgr=True, use_esdg=False, + use_overintegration=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.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -96,19 +93,10 @@ 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.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) # timestepping control timestepper = rk4_step @@ -508,8 +496,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -518,9 +507,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 or args.esdg, lazy=lazy, - casename=casename, rst_filename=rst_filename, actx_class=actx_class, - use_esdg=args.esdg) + 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 diff --git a/examples/poiseuille-mpi.py b/examples/poiseuille-mpi.py index 810dcf5a2..4c89d0fbe 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 @@ -83,16 +82,14 @@ 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, - rst_filename=None, actx_class=None, use_esdg=False): +def main(use_logmgr=True, use_esdg=False, + use_overintegration=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.") - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -107,19 +104,10 @@ 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.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) # timestepping control timestepper = rk4_step @@ -517,8 +505,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -527,9 +516,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 or args.esdg, lazy=lazy, - casename=casename, rst_filename=rst_filename, actx_class=actx_class, - use_esdg=args.esdg) + 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 diff --git a/examples/pulse-mpi.py b/examples/pulse-mpi.py index 35c348458..3b0f86c47 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, - use_overintegration=False, lazy=False, use_leap=False, use_profiling=False, - casename=None, rst_filename=None, use_esdg=False): +def main(actx_class, use_logmgr=True, use_esdg=False, + use_overintegration=False, use_leap=False, + casename=None, rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -98,19 +95,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.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) # timestepping control current_step = 0 @@ -403,8 +391,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -413,9 +402,9 @@ def my_rhs(t, state): if args.restart_file: rst_filename = args.restart_file - main(actx_class, use_logmgr=args.log, + main(actx_class, use_logmgr=args.log, use_esdg=args.esdg, use_overintegration=args.overintegration or args.esdg, - use_leap=args.leap, use_profiling=args.profiling, lazy=lazy, - casename=casename, rst_filename=rst_filename, use_esdg=args.esdg) + use_leap=args.leap, + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/scalar-advdiff-mpi.py b/examples/scalar-advdiff-mpi.py index 9caad93c8..7fe399048 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 @@ -72,13 +71,11 @@ 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_esdg=False, - use_overintegration=False): +def main(actx_class, use_logmgr=True, + use_overintegration=False, use_esdg=False, + use_leap=False, casename=None, + rst_filename=None): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -93,19 +90,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.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) # timestepping control current_step = 0 @@ -493,8 +481,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -503,8 +492,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, + main(actx_class, use_logmgr=args.log, use_leap=args.leap, use_overintegration=args.overintegration or args.esdg, use_esdg=args.esdg, - use_profiling=args.profiling, casename=casename, rst_filename=rst_filename) + casename=casename, rst_filename=rst_filename) # vim: foldmethod=marker diff --git a/examples/scalar-lump-mpi.py b/examples/scalar-lump-mpi.py index a024330dd..d208fc8f7 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 @@ -68,13 +67,11 @@ 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_overintegration=False, - use_esdg=False): +def main(actx_class, use_logmgr=True, + use_leap=False, casename=None, + use_overintegration=False, use_esdg=False, + rst_filename=None): """Drive example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -89,19 +86,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.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) # timestepping control current_step = 0 @@ -420,8 +408,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -430,8 +419,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, use_esdg=args.esdg, use_overintegration=args.esdg or args.overintegration) # vim: foldmethod=marker diff --git a/examples/sod-mpi.py b/examples/sod-mpi.py index 130fef78a..f766bd2f8 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,11 @@ 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_overintegration=False, use_esdg=False): +def main(actx_class, use_logmgr=True, + use_overintegration=False, use_esdg=False, + use_leap=False, casename=None, + rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -86,19 +84,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.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) # timestepping control if use_leap: @@ -415,8 +404,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -425,8 +415,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, use_overintegration=args.overintegration or args.esdg, use_esdg=args.esdg) # vim: foldmethod=marker diff --git a/examples/thermally-coupled-mpi.py b/examples/thermally-coupled-mpi.py index 84aeba4c6..cf2abd95a 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, update_wrapper 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,14 +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_esdg=False, use_overintegration=False, - use_leap=False, use_profiling=False, casename=None, - rst_filename=None, actx_class=None, lazy=False, - use_esdg=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,12 +105,6 @@ 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.inviscid import inviscid_facial_flux_rusanov from mirgecom.viscous import viscous_facial_flux_harmonic inviscid_numerical_flux_func = inviscid_facial_flux_rusanov @@ -123,13 +113,11 @@ def main(ctx_factory=cl.create_some_context, use_logmgr=True, inviscid_numerical_flux_func=inviscid_numerical_flux_func, viscous_numerical_flux_func=viscous_numerical_flux_func) update_wrapper(ns_op, ns_operator) - 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.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) # timestepping control current_step = 0 @@ -621,8 +609,9 @@ def my_rhs_and_gradients(t, state): if lazy: raise ValueError("Can't use lazy and profiling together.") - from grudge.array_context import get_reasonable_array_context_class - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -631,9 +620,9 @@ def my_rhs_and_gradients(t, state): if args.restart_file: rst_filename = args.restart_file - main(use_logmgr=args.log, use_overintegration=args.overintegration or args.esdg, - use_leap=args.leap, use_profiling=args.profiling, - casename=casename, rst_filename=rst_filename, actx_class=actx_class, - lazy=lazy, use_esdg=args.esdg) + main(use_logmgr=args.log, use_esdg=args.esdg, + use_overintegration=args.overintegration or args.esdg, + use_leap=args.leap, + casename=casename, rst_filename=rst_filename, actx_class=actx_class) # vim: foldmethod=marker diff --git a/examples/vortex-mpi.py b/examples/vortex-mpi.py index add6d84af..47a139dc0 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,12 +67,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, lazy=False, - rst_filename=None, use_overintegration=False, use_esdg=False): +def main(actx_class, use_logmgr=True, + use_overintegration=False, use_esdg=False, + use_leap=False, casename=None, rst_filename=None): """Drive the example.""" - cl_ctx = ctx_factory() - if casename is None: casename = "mirgecom" @@ -88,19 +85,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.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) current_step = 0 if use_leap: @@ -427,8 +415,9 @@ 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 - actx_class = get_reasonable_array_context_class(lazy=lazy, distributed=True) + from mirgecom.array_context import get_reasonable_array_context_class + 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: @@ -437,8 +426,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, use_overintegration=args.overintegration or args.esdg, use_esdg=args.esdg) # vim: foldmethod=marker diff --git a/examples/wave-mpi.py b/examples/wave-mpi.py index b9f25f4d9..5c6aecfae 100644 --- a/examples/wave-mpi.py +++ b/examples/wave-mpi.py @@ -23,29 +23,23 @@ """ 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,11 +63,8 @@ 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) - from mpi4py import MPI comm = MPI.COMM_WORLD rank = comm.Get_rank() @@ -81,23 +72,17 @@ 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.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) + 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 @@ -139,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))[()] + dt = actx.to_numpy(current_cfl + * op.nodal_min(dcoll, + "vol", nodal_dt))[()] # type: ignore[index] t_final = 1 @@ -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) @@ -247,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__": @@ -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.array_context 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..8631b71af 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,16 @@ 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.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) + use_profiling = actx_class_is_profiling(actx_class) dim = 2 nel_1d = 16 @@ -111,8 +86,9 @@ def main(actx_class, use_profiling=False, use_logmgr=False, lazy: bool = False): 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))[()] + dt = actx.to_numpy(current_cfl + * op.nodal_min(dcoll, "vol", + nodal_dt))[()] # type: ignore[index] print("%d elements" % mesh.nelements) @@ -157,6 +133,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, @@ -187,11 +165,11 @@ 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) + 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/array_context.py b/mirgecom/array_context.py new file mode 100644 index 000000000..5ab71a186 --- /dev/null +++ b/mirgecom/array_context.py @@ -0,0 +1,116 @@ +"""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 +import sys + +if TYPE_CHECKING or getattr(sys, "_BUILDING_SPHINX_DOCS", False): + # pylint: disable=no-name-in-module + from mpi4py.MPI import Comm + + +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") + + 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.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 343988b9a..71c60c092 100644 --- a/mirgecom/simutil.py +++ b/mirgecom/simutil.py @@ -63,24 +63,27 @@ 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 grudge.op import nodal_min, elementwise_min -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 +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 or getattr(sys, "_BUILDING_SPHINX_DOCS", False): + # pylint: disable=no-name-in-module + 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*.""" @@ -104,7 +107,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 @@ -207,7 +210,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 @@ -243,7 +246,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 @@ -892,7 +896,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) @@ -971,7 +976,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: @@ -1030,8 +1035,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") @@ -1075,8 +1080,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}.") @@ -1150,9 +1155,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