Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production actx init #925

Merged
merged 30 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
73a6c63
factor out actx init
matthiasdiener Jun 26, 2023
b815596
typing fixes
matthiasdiener Jun 27, 2023
f95c1f0
other examples
matthiasdiener Jun 27, 2023
e6e5843
linting
matthiasdiener Jun 28, 2023
3a3b5ca
pydocstyle
matthiasdiener Jun 28, 2023
9ffb079
MPIPytatoArrayContext
matthiasdiener Jun 28, 2023
7801ca2
add mirgecom/array_context.py, refactor
matthiasdiener Jun 28, 2023
60b9983
more fixes
matthiasdiener Jun 28, 2023
825478d
fix doc issues
matthiasdiener Jun 29, 2023
8508097
fix flake8
matthiasdiener Jun 29, 2023
03bb20e
Disable no member on pylint for MPI Comm.
MTCam Jun 29, 2023
016cb10
fix pylint
matthiasdiener Jun 29, 2023
5e99342
fix doc build
matthiasdiener Jun 29, 2023
176459f
enforce specifying all args to get_reasonable_array_context_class
matthiasdiener Jun 29, 2023
e4a1428
Correct placement of pylint disable?
MTCam Jun 29, 2023
36bb898
Disable pylint no-name-in-module for MPI.Comm
MTCam Jun 29, 2023
e6af90c
merge actx-init
MTCam Jun 29, 2023
661845a
Correct merge error
MTCam Jun 29, 2023
a804e68
Merge branch 'esdg-actx-init' into radiation-actx-init
MTCam Jun 29, 2023
95fe540
Merge upstream devel
MTCam Jun 29, 2023
86bc2b0
Merge branch 'build-production-actx-init' into production-actx-init
MTCam Jun 29, 2023
f87bdba
Unduplicate args to main
MTCam Jun 30, 2023
2a69446
Unduplicate args to main
MTCam Jun 30, 2023
2608d50
Merge branch 'esdg-actx-init' into radiation-actx-init
MTCam Jun 30, 2023
32ec53d
Merge branch 'radiation-actx-init' into build-production-actx-init
MTCam Jun 30, 2023
174ae2d
Merge branch 'build-production-actx-init' into production-actx-init
MTCam Jun 30, 2023
89e97d1
Remove unsed opt
MTCam Jun 30, 2023
e97c330
Merge branch 'esdg-actx-init' into radiation-actx-init
MTCam Jun 30, 2023
9863b5b
Merge branch 'radiation-actx-init' into build-production-actx-init
MTCam Jun 30, 2023
3cea3f0
Merge branch 'build-production-actx-init' into production-actx-init
MTCam Jun 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -- Project information -----------------------------------------------------
import sys

project = "mirgecom"
copyright = ("2020, University of Illinois Board of Trustees")
Expand Down Expand Up @@ -97,3 +98,5 @@
nitpick_ignore_regex = [
("py:class", r".*BoundaryDomainTag.*")
]

sys._BUILDING_SPHINX_DOCS = True
1 change: 1 addition & 0 deletions doc/support/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Random Pile'o'Tools

.. automodule:: mirgecom.simutil
.. automodule:: mirgecom.utils
.. automodule:: mirgecom.array_context
34 changes: 11 additions & 23 deletions examples/autoignition-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"""
import logging
import numpy as np
import pyopencl as cl
from functools import partial

from meshmode.mesh import BTAG_ALL
Expand Down Expand Up @@ -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"

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
38 changes: 11 additions & 27 deletions examples/combozzle-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
import time
import yaml
import numpy as np
import pyopencl as cl
from functools import partial

from meshmode.array_context import PyOpenCLArrayContext

from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa
from grudge.shortcuts import make_visualizer
from grudge.dof_desc import BoundaryDomainTag, DISCR_TAG_QUAD
Expand Down Expand Up @@ -161,15 +158,11 @@ 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,
rst_filename=None, actx_class=PyOpenCLArrayContext,
def main(actx_class, use_logmgr=True, rst_filename=None,
use_overintegration=False, casename=None,
log_dependent=False, input_file=None,
force_eval=True, use_esdg=False):
"""Drive example."""
cl_ctx = ctx_factory()

if casename is None:
casename = "mirgecom"

Expand Down Expand Up @@ -601,19 +594,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 = (
Expand Down Expand Up @@ -1295,8 +1279,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:
Expand All @@ -1314,10 +1299,9 @@ def dummy_rhs(t, state):

print(f"Calling main: {time.ctime(time.time())}")

main(use_logmgr=args.log, use_leap=args.leap, input_file=input_file,
main(actx_class, use_logmgr=args.log, 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,
casename=casename, rst_filename=rst_filename,
log_dependent=log_dependent, force_eval=force_eval, use_esdg=args.esdg)

# vim: foldmethod=marker
39 changes: 13 additions & 26 deletions examples/doublemach-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
35 changes: 11 additions & 24 deletions examples/doublemach_physical_av-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Loading