Skip to content

Commit

Permalink
other examples
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Jun 27, 2023
1 parent 8582216 commit ddc6819
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 278 deletions.
20 changes: 5 additions & 15 deletions examples/autoignition-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
20 changes: 4 additions & 16 deletions examples/combozzle-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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)

Expand Down
24 changes: 7 additions & 17 deletions examples/doublemach-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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
Expand Down Expand Up @@ -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
16 changes: 3 additions & 13 deletions examples/doublemach_physical_av-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 6 additions & 17 deletions examples/heat-source-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
25 changes: 7 additions & 18 deletions examples/hotplate-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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
Expand Down Expand Up @@ -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
23 changes: 6 additions & 17 deletions examples/lump-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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:
Expand Down Expand Up @@ -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
24 changes: 7 additions & 17 deletions examples/mixture-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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:
Expand Down Expand Up @@ -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
20 changes: 5 additions & 15 deletions examples/multiple-volumes-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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
Loading

0 comments on commit ddc6819

Please sign in to comment.