pygsti.tools.mpitools.gather_indices#
- gather_indices(indices, index_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 indices.
Upon entry it is assumed that the different processors within comm have computed different parts of ar_to_fill, namely different slices or index-arrays 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 indices given).
- Parameters:
indices (list) – A list of all the integer-arrays or slices (computed by any of the processors, not just the current one). Each element of indices may be either a single slice/index-array or a tuple of such elements (when gathering across multiple dimensions).
index_owners (dict) – A dictionary mapping the index of an element within slices to an integer rank of the processor responsible for communicating that slice/index-array’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 elements of indices refer to?). Note that len(axes) must be equal to the number of sub-indices (i.e. the tuple length) of each element of indices.
comm (mpi4py.MPI.Comm or None) – The communicator specifying the processors involved and used to perform the gather operation.
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