diff --git a/domain_decomposition.html b/domain_decomposition.html index 5307837..2a4b269 100644 --- a/domain_decomposition.html +++ b/domain_decomposition.html @@ -5,7 +5,7 @@ PyMPDATA_MPI.domain_decomposition API documentation - + @@ -22,26 +22,28 @@

Module PyMPDATA_MPI.domain_decomposition

+

MPI-aware domain decomposition utilities

Expand source code -
# pylint: disable=missing-module-docstring,missing-function-docstring,missing-class-docstring,invalid-name
+
""" MPI-aware domain decomposition utilities """
 
 import numpy as np
 from PyMPDATA.impl.domain_decomposition import make_subdomain
-from PyMPDATA.impl.enumerations import OUTER
-
-MPI_DIM = OUTER
 
 subdomain = make_subdomain(jit_flags={})
 
 
-def mpi_indices(grid, rank, size):
-    start, stop = subdomain(grid[MPI_DIM], rank, size)
-    xi, yi = np.indices((stop - start, grid[MPI_DIM - 1]), dtype=float)
-    xi += start
-    return xi, yi
+def mpi_indices(*, grid, rank, size, mpi_dim): + """returns a mapping from rank-local indices to domain-wide indices, + (subdomain-aware equivalent of np.indices)""" + start, stop = subdomain(grid[mpi_dim], rank, size) + indices_arg = list(grid) + indices_arg[mpi_dim] = stop - start + xyi = np.indices(tuple(indices_arg), dtype=float) + xyi[mpi_dim] += start + return xyi
@@ -52,19 +54,24 @@

Module PyMPDATA_MPI.domain_decomposition

Functions

-def mpi_indices(grid, rank, size) +def mpi_indices(*, grid, rank, size, mpi_dim)
-
+

returns a mapping from rank-local indices to domain-wide indices, +(subdomain-aware equivalent of np.indices)

Expand source code -
def mpi_indices(grid, rank, size):
-    start, stop = subdomain(grid[MPI_DIM], rank, size)
-    xi, yi = np.indices((stop - start, grid[MPI_DIM - 1]), dtype=float)
-    xi += start
-    return xi, yi
+
def mpi_indices(*, grid, rank, size, mpi_dim):
+    """returns a mapping from rank-local indices to domain-wide indices,
+    (subdomain-aware equivalent of np.indices)"""
+    start, stop = subdomain(grid[mpi_dim], rank, size)
+    indices_arg = list(grid)
+    indices_arg[mpi_dim] = stop - start
+    xyi = np.indices(tuple(indices_arg), dtype=float)
+    xyi[mpi_dim] += start
+    return xyi
diff --git a/impl/boundary_condition_commons.html b/impl/boundary_condition_commons.html index 5cced22..2e8ce46 100644 --- a/impl/boundary_condition_commons.html +++ b/impl/boundary_condition_commons.html @@ -27,20 +27,21 @@

Module PyMPDATA_MPI.impl.boundary_condition_commons Expand source code -
""" boundary_condition common functions """
+
# pylint: disable=too-many-arguments
+""" boundary_condition common functions """
 
 from functools import lru_cache
 
 import numba
 import numba_mpi as mpi
-from PyMPDATA.impl.enumerations import INVALID_INDEX
+from PyMPDATA.impl.enumerations import INVALID_INDEX, OUTER
 
 IRRELEVANT = 666
 
 
 @lru_cache()
 def make_scalar_boundary_condition(
-    indexers, jit_flags, dimension_index, dtype, get_peer
+    *, indexers, jit_flags, dimension_index, dtype, get_peer, mpi_dim
 ):
     """returns fill_halos() function for scalar boundary conditions.
     Provides default logic for scalar buffer filling. Notable arguments:
@@ -55,9 +56,10 @@ 

Module PyMPDATA_MPI.impl.boundary_condition_commonsModule PyMPDATA_MPI.impl.boundary_condition_commonsModule PyMPDATA_MPI.impl.boundary_condition_commonsModule PyMPDATA_MPI.impl.boundary_condition_commonsModule PyMPDATA_MPI.impl.boundary_condition_commonsModule PyMPDATA_MPI.impl.boundary_condition_commonsFunctions

-def make_scalar_boundary_condition(indexers, jit_flags, dimension_index, dtype, get_peer) +def make_scalar_boundary_condition(*, indexers, jit_flags, dimension_index, dtype, get_peer, mpi_dim)

returns fill_halos() function for scalar boundary conditions. @@ -173,7 +187,7 @@

Functions

@lru_cache()
 def make_scalar_boundary_condition(
-    indexers, jit_flags, dimension_index, dtype, get_peer
+    *, indexers, jit_flags, dimension_index, dtype, get_peer, mpi_dim
 ):
     """returns fill_halos() function for scalar boundary conditions.
     Provides default logic for scalar buffer filling. Notable arguments:
@@ -188,9 +202,10 @@ 

Functions

(i, INVALID_INDEX, k), psi, sign ) - send_recv = _make_send_recv(indexers.set, jit_flags, fill_buf, dtype, get_peer) + send_recv = _make_send_recv( + indexers.set, jit_flags, fill_buf, dtype, get_peer, mpi_dim + ) - # pylint: disable=too-many-arguments @numba.njit(**jit_flags) def fill_halos(buffer, i_rng, j_rng, k_rng, psi, _, sign): send_recv(buffer, psi, i_rng, j_rng, k_rng, sign, IRRELEVANT, psi) @@ -199,7 +214,7 @@

Functions

-def make_vector_boundary_condition(indexers, halo, jit_flags, dimension_index, dtype, get_peer) +def make_vector_boundary_condition(indexers, halo, jit_flags, dimension_index, dtype, get_peer, mpi_dim)

returns fill_halos() function for vector boundary conditions. @@ -211,8 +226,8 @@

Functions

Expand source code
@lru_cache()
-def make_vector_boundary_condition(  # pylint: disable=too-many-arguments
-    indexers, halo, jit_flags, dimension_index, dtype, get_peer
+def make_vector_boundary_condition(
+    indexers, halo, jit_flags, dimension_index, dtype, get_peer, mpi_dim
 ):
     """returns fill_halos() function for vector boundary conditions.
     Provides default logic for vector buffer filling. Notable arguments:
@@ -236,7 +251,9 @@ 

Functions

buf[i - i_rng.start, k - k_rng.start] = value - send_recv = _make_send_recv(indexers.set, jit_flags, fill_buf, dtype, get_peer) + send_recv = _make_send_recv( + indexers.set, jit_flags, fill_buf, dtype, get_peer, mpi_dim + ) @numba.njit(**jit_flags) def fill_halos_loop_vector(buffer, i_rng, j_rng, k_rng, components, dim, _, sign): diff --git a/impl/mpi_boundary_condition.html b/impl/mpi_boundary_condition.html index 8c1b9be..50500d5 100644 --- a/impl/mpi_boundary_condition.html +++ b/impl/mpi_boundary_condition.html @@ -35,10 +35,16 @@

Module PyMPDATA_MPI.impl.mpi_boundary_conditionModule PyMPDATA_MPI.impl.mpi_boundary_condition

+ indexers=indexers, + jit_flags=jit_flags, + dimension_index=dimension_index, + dtype=dtype, + get_peer=self.make_get_peer(jit_flags, self.worker_pool_size), + mpi_dim=self.mpi_dim, + )

@@ -72,7 +74,7 @@

Classes

class MPIBoundaryCondition -(base, size) +(base, size, mpi_dim)

common base class for MPI boundary conditions

@@ -83,10 +85,16 @@

Classes

class MPIBoundaryCondition:
     """common base class for MPI boundary conditions"""
 
-    def __init__(self, base, size):
+    def __init__(self, base, size, mpi_dim):
         self.__mpi_size_one = size == 1
         self.worker_pool_size = size
         self.base = base
+        self.mpi_dim = mpi_dim
+
+    @staticmethod
+    def make_get_peer(_, __):
+        """returns (lru-cached) numba-compiled callable."""
+        raise NotImplementedError()
 
     # pylint: disable=too-many-arguments
     def make_scalar(self, indexers, halo, dtype, jit_flags, dimension_index):
@@ -96,17 +104,13 @@ 

Classes

indexers, halo, dtype, jit_flags, dimension_index ) return make_scalar_boundary_condition( - indexers, - jit_flags, - dimension_index, - dtype, - self.make_get_peer(jit_flags, self.worker_pool_size), - ) - - @staticmethod - def make_get_peer(_, __): - """returns (lru-cached) numba-compiled callable.""" - raise NotImplementedError()
+ indexers=indexers, + jit_flags=jit_flags, + dimension_index=dimension_index, + dtype=dtype, + get_peer=self.make_get_peer(jit_flags, self.worker_pool_size), + mpi_dim=self.mpi_dim, + )

Subclasses

    @@ -149,11 +153,12 @@

    Methods

    indexers, halo, dtype, jit_flags, dimension_index ) return make_scalar_boundary_condition( - indexers, - jit_flags, - dimension_index, - dtype, - self.make_get_peer(jit_flags, self.worker_pool_size), + indexers=indexers, + jit_flags=jit_flags, + dimension_index=dimension_index, + dtype=dtype, + get_peer=self.make_get_peer(jit_flags, self.worker_pool_size), + mpi_dim=self.mpi_dim, )
diff --git a/index.html b/index.html index 93f5c04..8bde932 100644 --- a/index.html +++ b/index.html @@ -46,7 +46,7 @@

Sub-modules

PyMPDATA_MPI.domain_decomposition
-
+

MPI-aware domain decomposition utilities

PyMPDATA_MPI.hdf_storage
diff --git a/mpi_periodic.html b/mpi_periodic.html index 19556d9..3c75b24 100644 --- a/mpi_periodic.html +++ b/mpi_periodic.html @@ -45,13 +45,13 @@

Module PyMPDATA_MPI.mpi_periodic

`PyMPDATA.scalar_field.ScalarField` and `PyMPDATA.vector_field.VectorField` __init__ methods""" - def __init__(self, size): + def __init__(self, size, mpi_dim): # passing size insead of using mpi.size() because lack of support for non-default # MPI communicators. https://github.com/numba-mpi/numba-mpi/issues/64 assert SIGN_RIGHT == -1 assert SIGN_LEFT == +1 - super().__init__(size=size, base=Periodic) + super().__init__(size=size, base=Periodic, mpi_dim=mpi_dim) # pylint: disable=too-many-arguments def make_vector(self, indexers, halo, dtype, jit_flags, dimension_index): @@ -67,6 +67,7 @@

Module PyMPDATA_MPI.mpi_periodic

dimension_index, dtype, self.make_get_peer(jit_flags, self.worker_pool_size), + self.mpi_dim, ) @staticmethod @@ -96,7 +97,7 @@

Classes

class MPIPeriodic -(size) +(size, mpi_dim)

class which instances are to be passed in boundary_conditions tuple to the @@ -111,13 +112,13 @@

Classes

`PyMPDATA.scalar_field.ScalarField` and `PyMPDATA.vector_field.VectorField` __init__ methods""" - def __init__(self, size): + def __init__(self, size, mpi_dim): # passing size insead of using mpi.size() because lack of support for non-default # MPI communicators. https://github.com/numba-mpi/numba-mpi/issues/64 assert SIGN_RIGHT == -1 assert SIGN_LEFT == +1 - super().__init__(size=size, base=Periodic) + super().__init__(size=size, base=Periodic, mpi_dim=mpi_dim) # pylint: disable=too-many-arguments def make_vector(self, indexers, halo, dtype, jit_flags, dimension_index): @@ -133,6 +134,7 @@

Classes

dimension_index, dtype, self.make_get_peer(jit_flags, self.worker_pool_size), + self.mpi_dim, ) @staticmethod @@ -178,6 +180,7 @@

Methods

dimension_index, dtype, self.make_get_peer(jit_flags, self.worker_pool_size), + self.mpi_dim, )
diff --git a/mpi_polar.html b/mpi_polar.html index 3729b97..6666ccd 100644 --- a/mpi_polar.html +++ b/mpi_polar.html @@ -36,7 +36,6 @@

Module PyMPDATA_MPI.mpi_polar

from PyMPDATA.boundary_conditions import Polar from PyMPDATA.impl.enumerations import INNER, OUTER -from PyMPDATA_MPI.domain_decomposition import MPI_DIM from PyMPDATA_MPI.impl import MPIBoundaryCondition @@ -45,8 +44,8 @@

Module PyMPDATA_MPI.mpi_polar

`PyMPDATA.scalar_field.ScalarField` and `PyMPDATA.vector_field.VectorField` __init__ methods""" - def __init__(self, mpi_grid, grid): - self.worker_pool_size = grid[MPI_DIM] // mpi_grid[MPI_DIM] + def __init__(self, mpi_grid, grid, mpi_dim): + self.worker_pool_size = grid[mpi_dim] // mpi_grid[mpi_dim] self.__mpi_size_one = self.worker_pool_size == 1 if not self.__mpi_size_one: @@ -60,6 +59,7 @@

Module PyMPDATA_MPI.mpi_polar

if self.__mpi_size_one else None ), + mpi_dim=mpi_dim, ) @staticmethod @@ -92,7 +92,7 @@

Classes

class MPIPolar -(mpi_grid, grid) +(mpi_grid, grid, mpi_dim)

class which instances are to be passed in boundary_conditions tuple to the @@ -107,8 +107,8 @@

Classes

`PyMPDATA.scalar_field.ScalarField` and `PyMPDATA.vector_field.VectorField` __init__ methods""" - def __init__(self, mpi_grid, grid): - self.worker_pool_size = grid[MPI_DIM] // mpi_grid[MPI_DIM] + def __init__(self, mpi_grid, grid, mpi_dim): + self.worker_pool_size = grid[mpi_dim] // mpi_grid[mpi_dim] self.__mpi_size_one = self.worker_pool_size == 1 if not self.__mpi_size_one: @@ -122,6 +122,7 @@

Classes

if self.__mpi_size_one else None ), + mpi_dim=mpi_dim, ) @staticmethod