MPIArray#

class caput.mpiarray.MPIArray(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)[source]#

Bases: numpy.ndarray

A numpy-like array distributed across multiple processes.

Parameters:
global_shapeSequence[int]

The global shape of the array.

axisint, optional

The axis over which the array is distributed. Default is 0.

commMPI.Comm | None, optional

The communicator over which the array is distributed. Default is None, which will use MPI.COMM_WORLD.

argsAny, optional

Additional positional arguments to pass to the ndarray constructor.

**kwargsAny, optional

Additional keyword arguments to pass to the ndarray constructor.

property axis: int[source]#

Distributed axis.

Returns:
distributed_axisint
property comm: mpi4py.MPI.Comm[source]#

The communicator over which the array is distributed.

Returns:
commMPI.Comm
property global_shape: tuple[int, Ellipsis][source]#

Global array shape.

Returns:
global_shapetuple[int, …]
property global_slice: _global_resolver[source]#

Return an objects that presents a view of the array with global slicing.

Returns:
global_slice_resolver_global_resolver

_global_resolver instance.

property local_array: numpy.ndarray[source]#

rank-local numpy.ndarray view of the array.

Returns:
rank_local_arrayndarray
property local_bounds: slice[source]#

Global bounds of the local array along the distributed axis.

Returns:
rank_local_boundsslice
property local_offset: tuple[int, Ellipsis][source]#

Offset into global array.

This is equivalent to the global-index of the [0, 0, …] element of the local section.

Returns:
rank_local_offsettuple[int, …]
property local_shape: tuple[int, Ellipsis][source]#

Shape of local section.

Returns:
rank_local_shapeint

Methods#

__array_finalize__(→ None)

Finalizes the creation of the MPIArray, when viewed.

__array_ufunc__(→ MPIArray | tuple[MPIArray, ...)

Handles ufunc operations for MPIArray.

__getitem__(→ numpy.ndarray)

Returned a slice view of this array.

allgather(→ numpy.ndarray)

Gather a full copy onto each rank.

allreduce(→ numpy.number)

Perform MPI reduction op within memory buffer.

copy(→ MPIArray)

Return a copy of the MPIArray.

enumerate(→ collections.abc.Iterator[tuple[int, int]])

Helper for enumerating over a given axis.

from_file(→ MPIArray)

Read MPIArray from an HDF5 dataset or Zarr array on disk in parallel.

from_hdf5(→ MPIArray)

Read MPIArray from an HDF5 dataset in parallel.

gather(→ numpy.ndarray | None)

Gather a full copy onto a specific rank.

ravel(→ None)

Method is explicitly not implemented.

redistribute(→ MPIArray)

Change the rank distribution axis of the array.

reshape(→ MPIArray)

Reshape the array.

to_file(→ None)

Parallel write into a contiguous HDF5/Zarr dataset.

to_hdf5(→ None)

Parallel write into a contiguous HDF5 dataset.

to_zarr(→ None)

Parallel write into a contiguous Zarr dataset.

transpose(→ MPIArray)

Transpose the array axes.

wrap(→ MPIArray)

Turn ndarray`s spread across ranks into a distributed :py:class:.MPIArray` object.