From ddc681966e53cb01ba14a95387d4ad0bd5f4d896 Mon Sep 17 00:00:00 2001 From: Matthias Diener Date: Tue, 27 Jun 2023 18:30:05 -0500 Subject: [PATCH] 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