Skip to content

Commit

Permalink
Add MPINumpyArrayContext
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Jun 21, 2023
1 parent 9674514 commit 61ccd37
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions grudge/array_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.. autoclass:: PytatoPyOpenCLArrayContext
.. autoclass:: MPIBasedArrayContext
.. autoclass:: MPIPyOpenCLArrayContext
.. autoclass:: MPINumpyArrayContext
.. class:: MPIPytatoArrayContext
.. autofunction:: get_reasonable_array_context_class
"""
Expand Down Expand Up @@ -98,6 +99,8 @@
from arraycontext.container import ArrayContainer
from arraycontext.impl.pytato.compile import LazilyPyOpenCLCompilingFunctionCaller

from arraycontext import NumpyArrayContext

if TYPE_CHECKING:
import pytato as pt
from pytato.partition import PartId
Expand Down Expand Up @@ -459,6 +462,26 @@ def clone(self):
# }}}


# {{{ distributed + numpy

class MPINumpyArrayContext(NumpyArrayContext, MPIBasedArrayContext):
"""An array context for using distributed computation with :mod:`numpy`
eager evaluation.
.. autofunction:: __init__
"""

def __init__(self, mpi_communicator) -> None:
super().__init__()

self.mpi_communicator = mpi_communicator

def clone(self):
return type(self)(self.mpi_communicator)

# }}}


# {{{ distributed + pytato array context subclasses

class MPIBasePytatoPyOpenCLArrayContext(
Expand Down

0 comments on commit 61ccd37

Please sign in to comment.