sisl.mpi.Distribution

class sisl.mpi.Distribution

Bases: ABC

Maps n indices onto the ranks of comm.

Deliberately agnostic about what is being distributed. Calling a distribution on an object forwards to the object’s __sisl_distribute__ method, which decides what distributing it means:

dist(obj, *args, **kwargs)
# is
obj.__sisl_distribute__(dist, *args, **kwargs)

The communicator is held by the distribution. It defaults to the one sisl.mpi.get_comm hands out, so basic distributions need no communicator, but any communicator may be passed – e.g. a sub-communicator created by splitting the world communicator. The number of ranks, and the default rank queried by the methods, follow from it.

Subclasses supply range and owner. range returns every contiguous run a rank owns, as (start, stop) pairs – one run for a chunked scheme, several for a cyclic one – and indices, count and counts all follow from it.

Parameters:
  • n – number of indices to distribute

  • comm – communicator the indices are distributed across. Anything with rank and size attributes works; None means sisl.mpi.get_comm.

Methods

count([rank])

Number of indices owned by rank (default this process).

indices([rank])

The indices owned by rank (default this process), ascending.

owner(indices)

The rank owning each of indices.

range([rank])

The contiguous runs owned by rank, as ascending (start, stop) pairs.

Attributes

comm

The communicator the indices are distributed across.

counts

Number of indices owned by each rank.

n

Total number of indices across all ranks.

rank

The rank of this process in comm.

size

Number of ranks this is distributed across.

__call__(obj, *args, **kwargs)[source]

Distribute obj, by calling obj.__sisl_distribute__(self, *args, **kwargs).

count(rank=None)[source]

Number of indices owned by rank (default this process).

Parameters:

rank (int | None)

Return type:

int

indices(rank=None)[source]

The indices owned by rank (default this process), ascending.

Parameters:

rank (int | None)

Return type:

ndarray

abstractmethod owner(indices)[source]

The rank owning each of indices.

Return type:

ndarray

abstractmethod range(rank=None)[source]

The contiguous runs owned by rank, as ascending (start, stop) pairs.

A rank owning nothing gets an empty tuple. Runs are the primitive rather than a flat index array because they slice: a consumer can copy each run directly instead of gathering scattered elements.

Parameters:

rank (int | None) – defaults to the rank of this process.

Return type:

tuple[tuple[int, int], …]

property comm

The communicator the indices are distributed across.

property counts: ndarray

Number of indices owned by each rank.

property n: int

Total number of indices across all ranks.

property rank: int

The rank of this process in comm.

property size: int

Number of ranks this is distributed across.