pygsti.tools.mpitools.distribute_slice

pygsti.tools.mpitools.distribute_slice#

distribute_slice(s, comm, allow_split_comm=True)#

Partition a continuous slice evenly among comm’s processors.

This function is similar to distribute_indices(), but is specific to the case when the indices being distributed are a consecutive set of integers (specified by a slice).

Parameters:
  • s (slice) – The slice to be partitioned.

  • comm (mpi4py.MPI.Comm or ResourceAllocation) – The communicator which specifies the number of processors and which may be split into returned sub-communicators. If a ResourceAllocation object, node information is also taken into account when available (for shared memory compatibility).

  • allow_split_comm (bool) – If True, when there are more processors than slice indices, multiple processors will be given the same local slice and comm will be split into sub-communicators, one for each group of processors that are given the same local slice. If False, then “extra” processors are simply given nothing to do, i.e. an empty local slice.

Returns:

  • slices (list of slices) – The list of unique slices assigned to different processors. It’s possible that a single slice (i.e. element of slices) is assigned to multiple processors (when there are more processors than indices in s.

  • loc_slice (slice) – A slice specifying the indices belonging to the current processor.

  • owners (dict) – A dictionary giving the owning rank of each slice. Values are integer ranks and keys are integers into slices, specifying which slice.

  • loc_comm (mpi4py.MPI.Comm or ResourceAllocation or None) – The local communicator/ResourceAllocation for the group of processors which have been given the same loc_slice to compute, obtained by splitting comm. If loc_slice is unique to the current processor, or if allow_split_comm is False, None is returned.