pygsti.tools.mpitools.gather_slices

Contents

pygsti.tools.mpitools.gather_slices#

gather_slices(slices, slice_owners, ar_to_fill, ar_to_fill_inds, axes, comm, max_buffer_size=None)#

Gathers data within a numpy array, ar_to_fill, according to given slices.

Upon entry it is assumed that the different processors within comm have computed different parts of ar_to_fill, namely different slices of the axis-th axis. At exit, data has been gathered such that all processors have the results for the entire ar_to_fill (or at least for all the slices given).

Parameters:
  • slices (list) – A list of all the slices (computed by any of the processors, not just the current one). Each element of slices may be either a single slice or a tuple of slices (when gathering across multiple dimensions).

  • slice_owners (dict) – A dictionary mapping the index of a slice (or tuple of slices) within slices to an integer rank of the processor responsible for communicating that slice’s data to the rest of the processors.

  • ar_to_fill (numpy.ndarray) – The array which contains partial data upon entry and the gathered data upon exit.

  • ar_to_fill_inds (list) – A list of slice or index-arrays specifying the (fixed) sub-array of ar_to_fill that should be gathered into. The elements of ar_to_fill_inds are taken to be indices for the leading dimension first, and any unspecified dimensions or None elements are assumed to be unrestricted (as if slice(None,None)). Note that the combination of ar_to_fill and ar_to_fill_inds is essentially like passing ar_to_fill[ar_to_fill_inds] to this function, except it will work with index arrays as well as slices.

  • axes (int or tuple of ints) – The axis or axes of ar_to_fill on which the slices apply (which axis do the slices in slices refer to?). Note that len(axes) must be equal to the number of slices (i.e. the tuple length) of each element of slices.

  • comm (mpi4py.MPI.Comm or ResourceAllocation or None) – The communicator specifying the processors involved and used to perform the gather operation. If a ResourceAllocation is provided, then inter-host communication is used when available to facilitate use of shared intra-host memory.

  • max_buffer_size (int or None) – The maximum buffer size in bytes that is allowed to be used for gathering data. If None, there is no limit.

Return type:

None