pylops_mpi.basicoperators.MPIHalo#
- class pylops_mpi.basicoperators.MPIHalo(dims, halo, proc_grid_shape=None, comm=<mpi4py.MPI.Intracomm object>, dtype=<class 'numpy.float64'>)[source]#
MPI Halo
Apply haloing to all dimensions of a flattened, 1-dimensional
pylops_mpi.DistributedArrayafter local reshaping to a N-dimensional array.The Halo operator is applied over a Cartesian process grid, where each rank owns a local block of the global N-dimensional array.
- Parameters:
- dims
tuple Number of samples for each dimension.
- halo
intortuple Number of halo samples to add around each local block. A scalar value applies the same halo to both sides of every axis. A tuple of length
ndimapplies a symmetric halo per axis. A tuple of length2 * ndimspecifies the halo to apply at the start and at the end for each axis.- proc_grid_shape
tuple Number of MPI ranks along each dimension.
- comm
mpi4py.MPI.Comm, optional MPI Base Communicator. Defaults to
mpi4py.MPI.COMM_WORLD.- dtype
str, optional Type of elements in the input array.
- dims
- Attributes:
- shape
tuple Operator shape
- shape
Notes
The MPIHalo operator extends each rank’s local array with a halo (ghost cells) of width
haloalong the haloed axes, providing the neighboring rank’s data for stencil-like operators. Ranks are arranged in an N-dimensional Cartesian grid as provided byproc_grid_shape, whereby each rank owns a contiguous block of the global array. Thehalois normalised to a tuple of length2 * ndim, containing one(minus, plus)halo-width pair for each axis. The tuple is flattened in axis order as\[(h_{0,-}, h_{0,+}, h_{1,-}, h_{1,+}, \ldots)\]where \(h_{i,-}`\) and \(h_{i,+}`\) represent the halo widths on the negative and positive side of the i-th axis, respectively. For convenience,
halomay be provided as a scalar when the same symmetric halo is required along all axes, or as a tuple of lengthndimwhen symmetric halos of different width are applied to different axis. Ghost cells on the global boundary of an axis are zero by default.In the forward mode, each rank exchanges boundary slices with its left and right neighbors along each axis via
MPI_Sendrecv. Ranks at a global boundary haveMPI.PROC_NULLas their neighbor on that side, so those ghost regions remain zero and no exchange is attempted. Once the exchange is complete, local PyLops operators can be applied independently on each rank’s extended block, typically wrapped into apylops_mpi.basicoperators.MPIBlockDiagoperator.In the adjoint mode, the reverse operation is performed the original local domain is extracted by removing the ghost cells.
Finally, note that the Halo operator is not linear operator per se; instead, it is meant to sandwitch any linear operator to implement equivalent behaviours to the serial version of such an operator.
Methods
__init__(dims, halo[, proc_grid_shape, ...])adjoint()Adjoint MPI LinearOperator
conj()Complex conjugate operator
dot(x)Matrix Vector Multiplication
matvec(x)Matrix-vector multiplication.
rmatvec(x)Adjoint Matrix-vector multiplication.
transpose()Transposition of MPI LinearOperator