Skip to content

Commit

Permalink
Add MPINumpyArrayContext
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasdiener committed Sep 6, 2024
1 parent 245463d commit 66319b7
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 @@ -110,6 +111,8 @@
)


from arraycontext import NumpyArrayContext

if TYPE_CHECKING:
import pytato as pt
from mpi4py import MPI
Expand Down Expand Up @@ -468,6 +471,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 66319b7

Please sign in to comment.