PyMPDATA_MPI.impl.mpi_boundary_condition
common base class for MPI boundary conditions
1""" common base class for MPI boundary conditions """ 2 3from PyMPDATA_MPI.impl.boundary_condition_commons import make_scalar_boundary_condition 4 5 6class MPIBoundaryCondition: 7 """common base class for MPI boundary conditions""" 8 9 def __init__(self, base, size, mpi_dim): 10 self.__mpi_size_one = size == 1 11 self.worker_pool_size = size 12 self.base = base 13 self.mpi_dim = mpi_dim 14 15 @staticmethod 16 def make_get_peer(_, __): 17 """returns (lru-cached) numba-compiled callable.""" 18 raise NotImplementedError() 19 20 # pylint: disable=too-many-positional-arguments,too-many-arguments 21 def make_scalar(self, indexers, halo, dtype, jit_flags, dimension_index): 22 """returns (lru-cached) Numba-compiled scalar halo-filling callable""" 23 if self.__mpi_size_one: 24 return self.base.make_scalar( 25 indexers, halo, dtype, jit_flags, dimension_index 26 ) 27 return make_scalar_boundary_condition( 28 indexers=indexers, 29 jit_flags=jit_flags, 30 dimension_index=dimension_index, 31 dtype=dtype, 32 get_peer=self.make_get_peer(jit_flags, self.worker_pool_size), 33 mpi_dim=self.mpi_dim, 34 )
class
MPIBoundaryCondition:
7class MPIBoundaryCondition: 8 """common base class for MPI boundary conditions""" 9 10 def __init__(self, base, size, mpi_dim): 11 self.__mpi_size_one = size == 1 12 self.worker_pool_size = size 13 self.base = base 14 self.mpi_dim = mpi_dim 15 16 @staticmethod 17 def make_get_peer(_, __): 18 """returns (lru-cached) numba-compiled callable.""" 19 raise NotImplementedError() 20 21 # pylint: disable=too-many-positional-arguments,too-many-arguments 22 def make_scalar(self, indexers, halo, dtype, jit_flags, dimension_index): 23 """returns (lru-cached) Numba-compiled scalar halo-filling callable""" 24 if self.__mpi_size_one: 25 return self.base.make_scalar( 26 indexers, halo, dtype, jit_flags, dimension_index 27 ) 28 return make_scalar_boundary_condition( 29 indexers=indexers, 30 jit_flags=jit_flags, 31 dimension_index=dimension_index, 32 dtype=dtype, 33 get_peer=self.make_get_peer(jit_flags, self.worker_pool_size), 34 mpi_dim=self.mpi_dim, 35 )
common base class for MPI boundary conditions
@staticmethod
def
make_get_peer(_, __):
16 @staticmethod 17 def make_get_peer(_, __): 18 """returns (lru-cached) numba-compiled callable.""" 19 raise NotImplementedError()
returns (lru-cached) numba-compiled callable.
def
make_scalar(self, indexers, halo, dtype, jit_flags, dimension_index):
22 def make_scalar(self, indexers, halo, dtype, jit_flags, dimension_index): 23 """returns (lru-cached) Numba-compiled scalar halo-filling callable""" 24 if self.__mpi_size_one: 25 return self.base.make_scalar( 26 indexers, halo, dtype, jit_flags, dimension_index 27 ) 28 return make_scalar_boundary_condition( 29 indexers=indexers, 30 jit_flags=jit_flags, 31 dimension_index=dimension_index, 32 dtype=dtype, 33 get_peer=self.make_get_peer(jit_flags, self.worker_pool_size), 34 mpi_dim=self.mpi_dim, 35 )
returns (lru-cached) Numba-compiled scalar halo-filling callable