devito.mpi package¶

devito.mpi.distributed module¶

class devito.mpi.distributed.Distributor(shape, dimensions, input_comm=None)[source]

Bases: object

A class to perform domain decomposition for a set of MPI processes.

Parameters: shape – The shape of the domain to be decomposed. dimensions – The :class:Dimensions defining the domain. comm – An MPI communicator.
all_coords

Return an iterable containing the coordinates of each MPI rank in the decomposed domain. The iterable is order based on the MPI rank.

all_numb

Return an iterable containing the global numbering of each MPI rank.

all_ranges

Return an iterable containing the global ranges of each MPI rank.

comm
dimensions
glb_numb

Return the global numbering of this process’ domain section.

glb_pos_map

Return the mapper dimension -> side telling the position of the calling rank in the global grid.

glb_ranges

Return the global ranges of this process’ domain section.

glb_shape
glb_to_loc(dim, index)[source]

glb_to_loc(dim, offset, side) glb_to_loc(dim, (min, max))

Translate global indices into local indices.

Parameters: dim – The Dimension of the provided global indices. args – There are three possible cases: * args is a single integer I representing a global index. Then, the corresponding local index is returned if I is owned by self, otherwise None. args consists of two items, O and S – O is the offset the side S along dim. O is therefore an integer, while S is an object of type DataSide. Return the offset in the local domain, possibly 0 if the local range does not intersect with the region defined by the global offset. args is a tuple (min, max); return a 2-tuple (min’, max’), where min' and max' can be either None or an integer: min'=None means that min is not owned by self, but it precedes self’s minimum. Likewise, max'=None means that max is not owned by self, but it comes after self’s maximum. If min/max=int, then the integer can represent either the local index corresponding to the min/max, or it could be any random number such that max=min-1, meaning that the input argument does not represent a valid range for self.
glb_to_rank(index)[source]

Return the rank owning a given global index.

Parameters: index – A single domain index, or a list of domain indices. In the latter case, a list of corresponding ranks is returned.
mycoords
myrank
ndim
neighbours

Return the mapper proc -> side; proc is the rank of a neighboring process, while side tells whether proc is logically at right (value=1) or left (value=-1) of self.

nprocs
shape

Return the shape of this process’ domain.

topology

devito.mpi.halo_scheme module¶

class devito.mpi.halo_scheme.HaloScheme(exprs=None, ispace=None, dspace=None, fmapper=None)[source]

Bases: object

A HaloScheme describes a halo exchange pattern through a mapper:

M : Function -> HaloSchemeEntry


Where HaloSchemeEntry is a (named) 2-tuple:

({loc_indices}, ((Dimension, DataSide, amount), ...))


The tuples (Dimension, DataSide, amount) tell the amount of data that a TensorFunction should communicate along (a subset of) its :class:Dimensions.

The dict loc_indices tells how to access/insert the halo along the keyed Function’s non-halo indices. For example, consider the Function u(t, x, y). Assume x and y require a halo exchange. The question is: once the halo exchange is performed, at what offset in t should it be placed? should it be at u(0, ...) or u(1, ...) or even u(t-1, ...)? loc_indices has as many entries as non-halo dimensions, and each entry provides symbolic information about how to access the corresponding non-halo dimension. Thus, in this example loc_indices could be, for instance, {t: 0} or {t: t-1}.

Parameters: exprs – The :class:IREqs for which the HaloScheme is built. ispace – A IterationSpace describing the iteration directions and the sub-iterators used by the exprs. dspace – A DataSpace describing the exprs data access pattern. fmapper – (Optional) Alternatively, a HaloScheme can be built from a set of known HaloSchemeEntry. If fmapper is provided, then exprs, ispace, and dspace are ignored. fmapper is a dictionary having same format as M, the HaloScheme mapper defined at the top of this docstring.
fmapper
mask
exception devito.mpi.halo_scheme.HaloSchemeException[source]

Bases: Exception

devito.mpi.routines module¶

devito.mpi.routines.copy(f, fixed, swap=False)[source]

Construct a Callable capable of copying:

* an arbitrary convex region of f into a contiguous :class:Array, OR
* if swap=True, a contiguous :class:Array into an arbitrary convex
region of f.

devito.mpi.routines.sendrecv(f, fixed)[source]

Construct an IET performing a halo exchange along arbitrary dimension and side.

devito.mpi.routines.update_halo(f, fixed)[source]

Construct an IET performing a halo exchange for a TensorFunction.

devito.mpi.utils module¶

devito.mpi.utils.get_views(f, fixed)[source]

Return a mapper (dimension, side, region) -> (size, offset) for a TensorFunction.