maybempi
Type part of a name or a dotted path
Use MPI only when the process was launched under MPI, and a serial stand-in otherwise.
Importing mpi4py.MPI starts MPI, which costs close to a second and makes every
collective cost something, even on one process. maybempi decides from the
environment the launcher sets up, without importing mpi4py, and returns either
mpi4py.MPI or a serial stand-in with the same interface::
import maybempi
MPI = maybempi.get_mpi() # mpi4py.MPI under mpirun/srun, else the stand-incomm = MPI.COMM_WORLDtotal = comm.allreduce(local_total, op=MPI.SUM)from maybempi import MPI is the drop-in replacement for from mpi4py import MPI: the name resolves to get_mpi() when it is first imported.
:mod:maybempi.launch holds the detection, :mod:maybempi.serial the stand-in.
Attributes
| Name | Description |
|---|---|
LAUNCHER_VARIABLES | No description. |
LOCAL_RANK_VARIABLES | No description. |
OVERRIDE_VARIABLE | No description. |
__version__ | No description. |
Classes
| Name | Description |
|---|---|
SerialCartcomm | Stand-in for MPI.Cartcomm: a Cartesian grid of one process. |
SerialComm | A communicator of size 1, with the mpi4py Comm methods a serial run needs. |
SerialFile | Stand-in for mpi4py.MPI.File: a file opened by the only process. |
SerialGroup | Stand-in for MPI.Group: rank 0 alone, or the empty group. |
SerialMPI | Stand-in for the mpi4py.MPI module in a serial run. |
SerialPrequest | A persistent request (Send_init/Recv_init): each Start posts it again. |
SerialRequest | A request of a non-blocking call of :class:SerialComm. |
SerialStatus | Stand-in for MPI.Status: the source, tag and size of a received message. |
Functions
| Name | Description |
|---|---|
get_mpi | Return mpi4py.MPI for an MPI run, else the serial stand-in. |
is_serial | Tell whether obj is the serial stand-in (the module or a communicator). |
launched_under_mpi | Tell whether this process was started by an MPI launcher, without importing mpi4py. |
launcher_variable | Return the first variable of :data:LAUNCHER_VARIABLES that is set, if any. |
local_rank | Return the rank of this process within its node, from the launcher's environment. |
set_copy_hook | Report copies between device and host arrays in buffer collectives. |
Modules
LAUNCHER_VARIABLESattributemodule attribute#
maybempi.launchView sourceLAUNCHER_VARIABLES = (
'OMPI_COMM_WORLD_RANK',
'PMI_RANK',
'PMIX_RANK',
'MV2_COMM_WORLD_RANK',
'MPI_LOCALRANKID',
'ALPS_APP_PE',
'PALS_RANKID'
)LOCAL_RANK_VARIABLESattributemodule attribute#
maybempi.launchView sourceLOCAL_RANK_VARIABLES = (
'OMPI_COMM_WORLD_LOCAL_RANK',
'MV2_COMM_WORLD_LOCAL_RANK',
'MPI_LOCALRANKID',
'PMI_LOCAL_RANK',
'PALS_LOCAL_RANKID',
'SLURM_LOCALID',
'LOCAL_RANK'
)OVERRIDE_VARIABLEattributemodule attribute#
maybempi.launchView sourceOVERRIDE_VARIABLE = 'MAYBEMPI'__version__attributemodule attribute#
__version__ = version('maybempi')SerialCartcommclass#
maybempi.serialView sourceclass SerialCartcomm(dims: Sequence[int], periods: Sequence[bool | int], name: str = 'COMM_WORLD')Bases: SerialComm
Stand-in for MPI.Cartcomm: a Cartesian grid of one process.
Every dimension has length 1. Along a periodic dimension rank 0 is its own
neighbour; along the others Shift gives PROC_NULL.
Cloneattributeclass attributeinstance attribute#
Clone = Dupcoordsproperty#
coords: list[int]The coordinates of this process (all 0).
dimsproperty#
dims: list[int]The processes along each dimension (all 1).
ndimproperty#
ndim: intThe number of dimensions.
periodsproperty#
periods: list[int]Whether each dimension is periodic, as 0 or 1.
topoproperty#
topo: tuple[list[int], list[int], list[int]](dims, periods, coords).
Dupmethod#
def Dup(info: Any = None) -> SerialCartcommReturn a new Cartesian communicator with the same grid.
Get_cart_rankmethod#
def Get_cart_rank(coords: Sequence[int]) -> intReturn 0 for coordinates on the grid (any along periodic dimensions).
Get_coordsmethod#
def Get_coords(rank: int) -> list[int]Return the coordinates of rank (only 0 exists).
Get_dimmethod#
def Get_dim() -> intReturn the number of dimensions.
Get_topomethod#
def Get_topo() -> tuple[list[int], list[int], list[int]]Return (dims, periods, coords).
Get_topologymethod#
def Get_topology() -> intReturn CART.
Shiftmethod#
def Shift(direction: int, disp: int) -> tuple[int, int]Return (source, dest): 0 along periodic dimensions, else PROC_NULL.
Submethod#
def Sub(remain_dims: Sequence[bool]) -> SerialCartcommReturn the grid of the dimensions in remain_dims.
Inherited from maybempi.serial.SerialComm
Bsendattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceBsend = SendBsend_initattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceBsend_init = Send_initIbsendattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceIbsend = IsendIrsendattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceIrsend = IsendRsendattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceRsend = SendRsend_initattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceRsend_init = Send_initbarrierattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourcebarrier = Barrierbsendattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourcebsend = sendibsendattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceibsend = isendiprobeattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceiprobe = Iprobeprobeattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourceprobe = Proberankattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourcerank = 0sizeattributeclass attributeinstance attribute#
maybempi.serial.SerialCommView sourcesize = 1groupproperty#
maybempi.serial.SerialCommView sourcegroup: SerialGroupThe group of the communicator.
topologyproperty#
maybempi.serial.SerialCommView sourcetopology: intThe topology: UNDEFINED.
Abortmethod#
maybempi.serial.SerialCommView sourcedef Abort(errorcode: int = 0) -> NoneExit the process with errorcode (SystemExit).
Allgathermethod#
maybempi.serial.SerialCommView sourcedef Allgather(sendbuf: Any, recvbuf: Any) -> NoneCopy sendbuf into recvbuf.
Allgathervmethod#
maybempi.serial.SerialCommView sourcedef Allgatherv(sendbuf: Any, recvbuf: Any) -> NoneCopy sendbuf into recvbuf, at the displacement of rank 0.
Allreducemethod#
maybempi.serial.SerialCommView sourcedef Allreduce(sendbuf: Any, recvbuf: Any, op: Any = None) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Alltoallmethod#
maybempi.serial.SerialCommView sourcedef Alltoall(sendbuf: Any, recvbuf: Any) -> NoneCopy sendbuf into recvbuf.
Alltoallvmethod#
maybempi.serial.SerialCommView sourcedef Alltoallv(sendbuf: Any, recvbuf: Any) -> NoneCopy the part of sendbuf for rank 0 into recvbuf, at the displacement of rank 0.
Barriermethod#
maybempi.serial.SerialCommView sourcedef Barrier() -> NoneReturn at once.
Bcastmethod#
maybempi.serial.SerialCommView sourcedef Bcast(buf: Any, root: int = 0) -> NoneDo nothing: rank 0 already has the data.
Createmethod#
maybempi.serial.SerialCommView sourcedef Create(group: SerialGroup) -> AnyReturn a communicator for group: a new one, or COMM_NULL if empty.
Create_cartmethod#
maybempi.serial.SerialCommView sourcedef Create_cart(dims: Sequence[int], periods: Sequence[bool] | None = None, reorder: bool = False) -> SerialCartcommReturn a Cartesian communicator; the dimensions must multiply to 1.
Raises
ValueError- If the grid needs more than one process.
Create_groupmethod#
maybempi.serial.SerialCommView sourcedef Create_group(group: SerialGroup, tag: int = 0) -> AnyReturn a communicator for group: a new one, or COMM_NULL if empty.
Exscanmethod#
maybempi.serial.SerialCommView sourcedef Exscan(sendbuf: Any, recvbuf: Any, op: Any = None) -> NoneDo nothing: the receive buffer of rank 0 is undefined.
Freemethod#
maybempi.serial.SerialCommView sourcedef Free() -> NoneDo nothing.
Gathermethod#
maybempi.serial.SerialCommView sourcedef Gather(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy sendbuf into recvbuf.
Gathervmethod#
maybempi.serial.SerialCommView sourcedef Gatherv(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy sendbuf into recvbuf, at the displacement of rank 0.
Get_groupmethod#
maybempi.serial.SerialCommView sourcedef Get_group() -> SerialGroupReturn the group of the communicator: rank 0 only.
Get_namemethod#
maybempi.serial.SerialCommView sourcedef Get_name() -> strReturn the name of the communicator, e.g. "COMM_WORLD".
Get_rankmethod#
maybempi.serial.SerialCommView sourcedef Get_rank() -> intReturn 0.
Get_sizemethod#
maybempi.serial.SerialCommView sourcedef Get_size() -> intReturn 1.
Iallgathermethod#
maybempi.serial.SerialCommView sourcedef Iallgather(sendbuf: Any, recvbuf: Any) -> SerialRequestCopy like Allgather and return a completed request.
Iallreducemethod#
maybempi.serial.SerialCommView sourcedef Iallreduce(sendbuf: Any, recvbuf: Any, op: Any = None) -> SerialRequestCopy like Allreduce and return a completed request.
Ibarriermethod#
maybempi.serial.SerialCommView sourcedef Ibarrier() -> SerialRequestReturn a completed request.
Ibcastmethod#
maybempi.serial.SerialCommView sourcedef Ibcast(buf: Any, root: int = 0) -> SerialRequestReturn a completed request (Bcast does nothing).
Iprobemethod#
maybempi.serial.SerialCommView sourcedef Iprobe(source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> boolReturn whether a matching message is waiting, without receiving it.
Irecvmethod#
maybempi.serial.SerialCommView sourcedef Irecv(buf: Any, source: int = _ANY_SOURCE, tag: int = _ANY_TAG) -> SerialRequestPost a receive into buf; complete once a matching message is sent.
Is_intermethod#
maybempi.serial.SerialCommView sourcedef Is_inter() -> boolReturn False.
Is_intramethod#
maybempi.serial.SerialCommView sourcedef Is_intra() -> boolReturn True.
Isendmethod#
maybempi.serial.SerialCommView sourcedef Isend(buf: Any, dest: int, tag: int = 0) -> SerialRequestSend buf and return a completed request (the data are copied).
Issendmethod#
maybempi.serial.SerialCommView sourcedef Issend(buf: Any, dest: int, tag: int = 0) -> SerialRequestSend synchronously: the request completes when a receive takes it.
Probemethod#
maybempi.serial.SerialCommView sourcedef Probe(source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> boolReturn True for a waiting message (RuntimeError if none was sent).
Recvmethod#
maybempi.serial.SerialCommView sourcedef Recv(buf: Any, source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> NoneReceive into buf (RuntimeError if no matching message was sent).
Recv_initmethod#
maybempi.serial.SerialCommView sourcedef Recv_init(buf: Any, source: int = _ANY_SOURCE, tag: int = _ANY_TAG) -> SerialPrequestReturn a persistent receive: each Start posts a receive into buf.
Reducemethod#
maybempi.serial.SerialCommView sourcedef Reduce(sendbuf: Any, recvbuf: Any, op: Any = None, root: int = 0) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Scanmethod#
maybempi.serial.SerialCommView sourcedef Scan(sendbuf: Any, recvbuf: Any, op: Any = None) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Scattermethod#
maybempi.serial.SerialCommView sourcedef Scatter(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Scattervmethod#
maybempi.serial.SerialCommView sourcedef Scatterv(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy the part of sendbuf at the displacement of rank 0 into recvbuf.
Sendmethod#
maybempi.serial.SerialCommView sourcedef Send(buf: Any, dest: int, tag: int = 0) -> NoneSend buf to dest (0, or PROC_NULL); kept until received.
Send_initmethod#
maybempi.serial.SerialCommView sourcedef Send_init(buf: Any, dest: int, tag: int = 0) -> SerialPrequestReturn a persistent send: each Start sends buf.
Sendrecvmethod#
maybempi.serial.SerialCommView sourcedef Sendrecv(sendbuf: Any, dest: int, sendtag: int = 0, recvbuf: Any = None, source: int = _ANY_SOURCE, recvtag: int = _ANY_TAG, status: Any = None) -> NoneSend sendbuf to dest and receive into recvbuf from source.
With dest=0, source=0 that copies sendbuf into recvbuf; with
PROC_NULL the send or the receive does nothing.
Sendrecv_replacemethod#
maybempi.serial.SerialCommView sourcedef Sendrecv_replace(buf: Any, dest: int, sendtag: int = 0, source: int = _ANY_SOURCE, recvtag: int = _ANY_TAG, status: Any = None) -> NoneSend buf to dest, then receive into buf from source.
Splitmethod#
maybempi.serial.SerialCommView sourcedef Split(color: int = 0, key: int = 0) -> AnyReturn a new serial communicator, or COMM_NULL for color=UNDEFINED.
Split_typemethod#
maybempi.serial.SerialCommView sourcedef Split_type(split_type: int, key: int = 0, info: Any = None) -> AnyReturn a new serial communicator, or COMM_NULL for UNDEFINED.
Ssendmethod#
maybempi.serial.SerialCommView sourcedef Ssend(buf: Any, dest: int, tag: int = 0) -> NoneSend synchronously: a matching receive must already be posted.
Ssend_initmethod#
maybempi.serial.SerialCommView sourcedef Ssend_init(buf: Any, dest: int, tag: int = 0) -> SerialPrequestReturn a persistent synchronous send.
allgathermethod#
maybempi.serial.SerialCommView sourcedef allgather(sendobj: Any) -> list[Any]Return [sendobj].
allreducemethod#
maybempi.serial.SerialCommView sourcedef allreduce(sendobj: Any, op: Any = None) -> AnyReturn sendobj.
alltoallmethod#
maybempi.serial.SerialCommView sourcedef alltoall(sendobj: Any) -> list[Any]Return sendobj as a list (ValueError unless it has one item).
bcastmethod#
maybempi.serial.SerialCommView sourcedef bcast(obj: Any, root: int = 0) -> AnyReturn obj.
exscanmethod#
maybempi.serial.SerialCommView sourcedef exscan(sendobj: Any, op: Any = None) -> NoneReturn None: the result is undefined on rank 0 (None in mpi4py).
gathermethod#
maybempi.serial.SerialCommView sourcedef gather(sendobj: Any, root: int = 0) -> list[Any]Return [sendobj].
iallreducemethod#
maybempi.serial.SerialCommView sourcedef iallreduce(sendobj: Any, op: Any = None) -> SerialRequestReturn a completed request whose wait() returns sendobj.
ibcastmethod#
maybempi.serial.SerialCommView sourcedef ibcast(obj: Any, root: int = 0) -> SerialRequestReturn a completed request whose wait() returns obj.
irecvmethod#
maybempi.serial.SerialCommView sourcedef irecv(buf: Any = None, source: int = _ANY_SOURCE, tag: int = _ANY_TAG) -> SerialRequestPost an object receive; wait() returns the object.
isendmethod#
maybempi.serial.SerialCommView sourcedef isend(obj: Any, dest: int, tag: int = 0) -> SerialRequestSend a (pickled) object and return a completed request.
issendmethod#
maybempi.serial.SerialCommView sourcedef issend(obj: Any, dest: int, tag: int = 0) -> SerialRequestSend an object synchronously: complete when a receive takes it.
recvmethod#
maybempi.serial.SerialCommView sourcedef recv(buf: Any = None, source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> AnyReturn a received object (None from PROC_NULL).
reducemethod#
maybempi.serial.SerialCommView sourcedef reduce(sendobj: Any, op: Any = None, root: int = 0) -> AnyReturn sendobj.
scanmethod#
maybempi.serial.SerialCommView sourcedef scan(sendobj: Any, op: Any = None) -> AnyReturn sendobj.
scattermethod#
maybempi.serial.SerialCommView sourcedef scatter(sendobj: Any, root: int = 0) -> AnyReturn the only item of sendobj (ValueError unless it has one).
sendmethod#
maybempi.serial.SerialCommView sourcedef send(obj: Any, dest: int, tag: int = 0) -> NoneSend a (pickled) object to dest.
sendrecvmethod#
maybempi.serial.SerialCommView sourcedef sendrecv(sendobj: Any, dest: int, sendtag: int = 0, recvbuf: Any = None, source: int = _ANY_SOURCE, recvtag: int = _ANY_TAG, status: Any = None) -> AnySend sendobj to dest and return the object received from source.
With dest=0, source=0 that is a copy of sendobj (unless an earlier
message matches first); None with source=PROC_NULL.
ssendmethod#
maybempi.serial.SerialCommView sourcedef ssend(obj: Any, dest: int, tag: int = 0) -> NoneSend an object synchronously: a matching receive must be posted.
SerialCommclass#
maybempi.serialView sourceclass SerialComm(name: str = 'COMM_WORLD')A communicator of size 1, with the mpi4py Comm methods a serial run needs.
Collectives return (object methods) or copy (buffer methods) what they would
on one rank: allreduce(x) is x, gather(x) is [x],
Allreduce(send, recv) copies send into recv (nothing with
IN_PLACE), Bcast does nothing. Point-to-point messages go to and
come from rank 0 itself or PROC_NULL: a send is kept, per
communicator, until a receive with a matching tag takes it, in the order
sent. A blocking receive with no matching message raises RuntimeError
(MPI would wait forever). Other methods raise AttributeError.
Attributes
| Name | Description |
|---|---|
rank | Always 0. |
size | Always 1. |
Bsendattributeclass attributeinstance attribute#
Bsend = SendBsend_initattributeclass attributeinstance attribute#
Bsend_init = Send_initCloneattributeclass attributeinstance attribute#
Clone = DupIbsendattributeclass attributeinstance attribute#
Ibsend = IsendIrsendattributeclass attributeinstance attribute#
Irsend = IsendRsendattributeclass attributeinstance attribute#
Rsend = SendRsend_initattributeclass attributeinstance attribute#
Rsend_init = Send_initbarrierattributeclass attributeinstance attribute#
barrier = Barrierbsendattributeclass attributeinstance attribute#
bsend = sendibsendattributeclass attributeinstance attribute#
ibsend = isendiprobeattributeclass attributeinstance attribute#
iprobe = Iprobeprobeattributeclass attributeinstance attribute#
probe = Proberankattributeclass attributeinstance attribute#
rank = 0sizeattributeclass attributeinstance attribute#
size = 1groupproperty#
group: SerialGroupThe group of the communicator.
topologyproperty#
topology: intThe topology: UNDEFINED.
Abortmethod#
def Abort(errorcode: int = 0) -> NoneExit the process with errorcode (SystemExit).
Allgathermethod#
def Allgather(sendbuf: Any, recvbuf: Any) -> NoneCopy sendbuf into recvbuf.
Allgathervmethod#
def Allgatherv(sendbuf: Any, recvbuf: Any) -> NoneCopy sendbuf into recvbuf, at the displacement of rank 0.
Allreducemethod#
def Allreduce(sendbuf: Any, recvbuf: Any, op: Any = None) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Alltoallmethod#
def Alltoall(sendbuf: Any, recvbuf: Any) -> NoneCopy sendbuf into recvbuf.
Alltoallvmethod#
def Alltoallv(sendbuf: Any, recvbuf: Any) -> NoneCopy the part of sendbuf for rank 0 into recvbuf, at the displacement of rank 0.
Barriermethod#
def Barrier() -> NoneReturn at once.
Bcastmethod#
def Bcast(buf: Any, root: int = 0) -> NoneDo nothing: rank 0 already has the data.
Createmethod#
def Create(group: SerialGroup) -> AnyReturn a communicator for group: a new one, or COMM_NULL if empty.
Create_cartmethod#
def Create_cart(dims: Sequence[int], periods: Sequence[bool] | None = None, reorder: bool = False) -> SerialCartcommReturn a Cartesian communicator; the dimensions must multiply to 1.
Raises
ValueError- If the grid needs more than one process.
Create_groupmethod#
def Create_group(group: SerialGroup, tag: int = 0) -> AnyReturn a communicator for group: a new one, or COMM_NULL if empty.
Dupmethod#
def Dup(info: Any = None) -> SerialCommReturn a new serial communicator with the same name.
Exscanmethod#
def Exscan(sendbuf: Any, recvbuf: Any, op: Any = None) -> NoneDo nothing: the receive buffer of rank 0 is undefined.
Freemethod#
def Free() -> NoneDo nothing.
Gathermethod#
def Gather(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy sendbuf into recvbuf.
Gathervmethod#
def Gatherv(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy sendbuf into recvbuf, at the displacement of rank 0.
Get_groupmethod#
def Get_group() -> SerialGroupReturn the group of the communicator: rank 0 only.
Get_namemethod#
def Get_name() -> strReturn the name of the communicator, e.g. "COMM_WORLD".
Get_rankmethod#
def Get_rank() -> intReturn 0.
Get_sizemethod#
def Get_size() -> intReturn 1.
Get_topologymethod#
def Get_topology() -> intReturn UNDEFINED: no topology.
Iallgathermethod#
def Iallgather(sendbuf: Any, recvbuf: Any) -> SerialRequestCopy like Allgather and return a completed request.
Iallreducemethod#
def Iallreduce(sendbuf: Any, recvbuf: Any, op: Any = None) -> SerialRequestCopy like Allreduce and return a completed request.
Ibarriermethod#
def Ibarrier() -> SerialRequestReturn a completed request.
Ibcastmethod#
def Ibcast(buf: Any, root: int = 0) -> SerialRequestReturn a completed request (Bcast does nothing).
Iprobemethod#
def Iprobe(source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> boolReturn whether a matching message is waiting, without receiving it.
Irecvmethod#
def Irecv(buf: Any, source: int = _ANY_SOURCE, tag: int = _ANY_TAG) -> SerialRequestPost a receive into buf; complete once a matching message is sent.
Is_intermethod#
def Is_inter() -> boolReturn False.
Is_intramethod#
def Is_intra() -> boolReturn True.
Isendmethod#
def Isend(buf: Any, dest: int, tag: int = 0) -> SerialRequestSend buf and return a completed request (the data are copied).
Issendmethod#
def Issend(buf: Any, dest: int, tag: int = 0) -> SerialRequestSend synchronously: the request completes when a receive takes it.
Probemethod#
def Probe(source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> boolReturn True for a waiting message (RuntimeError if none was sent).
Recvmethod#
def Recv(buf: Any, source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> NoneReceive into buf (RuntimeError if no matching message was sent).
Recv_initmethod#
def Recv_init(buf: Any, source: int = _ANY_SOURCE, tag: int = _ANY_TAG) -> SerialPrequestReturn a persistent receive: each Start posts a receive into buf.
Reducemethod#
def Reduce(sendbuf: Any, recvbuf: Any, op: Any = None, root: int = 0) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Scanmethod#
def Scan(sendbuf: Any, recvbuf: Any, op: Any = None) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Scattermethod#
def Scatter(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy sendbuf into recvbuf (nothing with IN_PLACE).
Scattervmethod#
def Scatterv(sendbuf: Any, recvbuf: Any, root: int = 0) -> NoneCopy the part of sendbuf at the displacement of rank 0 into recvbuf.
Sendmethod#
def Send(buf: Any, dest: int, tag: int = 0) -> NoneSend buf to dest (0, or PROC_NULL); kept until received.
Send_initmethod#
def Send_init(buf: Any, dest: int, tag: int = 0) -> SerialPrequestReturn a persistent send: each Start sends buf.
Sendrecvmethod#
def Sendrecv(sendbuf: Any, dest: int, sendtag: int = 0, recvbuf: Any = None, source: int = _ANY_SOURCE, recvtag: int = _ANY_TAG, status: Any = None) -> NoneSend sendbuf to dest and receive into recvbuf from source.
With dest=0, source=0 that copies sendbuf into recvbuf; with
PROC_NULL the send or the receive does nothing.
Sendrecv_replacemethod#
def Sendrecv_replace(buf: Any, dest: int, sendtag: int = 0, source: int = _ANY_SOURCE, recvtag: int = _ANY_TAG, status: Any = None) -> NoneSend buf to dest, then receive into buf from source.
Splitmethod#
def Split(color: int = 0, key: int = 0) -> AnyReturn a new serial communicator, or COMM_NULL for color=UNDEFINED.
Split_typemethod#
def Split_type(split_type: int, key: int = 0, info: Any = None) -> AnyReturn a new serial communicator, or COMM_NULL for UNDEFINED.
Ssendmethod#
def Ssend(buf: Any, dest: int, tag: int = 0) -> NoneSend synchronously: a matching receive must already be posted.
Ssend_initmethod#
def Ssend_init(buf: Any, dest: int, tag: int = 0) -> SerialPrequestReturn a persistent synchronous send.
allgathermethod#
def allgather(sendobj: Any) -> list[Any]Return [sendobj].
allreducemethod#
def allreduce(sendobj: Any, op: Any = None) -> AnyReturn sendobj.
alltoallmethod#
def alltoall(sendobj: Any) -> list[Any]Return sendobj as a list (ValueError unless it has one item).
bcastmethod#
def bcast(obj: Any, root: int = 0) -> AnyReturn obj.
exscanmethod#
def exscan(sendobj: Any, op: Any = None) -> NoneReturn None: the result is undefined on rank 0 (None in mpi4py).
gathermethod#
def gather(sendobj: Any, root: int = 0) -> list[Any]Return [sendobj].
iallreducemethod#
def iallreduce(sendobj: Any, op: Any = None) -> SerialRequestReturn a completed request whose wait() returns sendobj.
ibcastmethod#
def ibcast(obj: Any, root: int = 0) -> SerialRequestReturn a completed request whose wait() returns obj.
irecvmethod#
def irecv(buf: Any = None, source: int = _ANY_SOURCE, tag: int = _ANY_TAG) -> SerialRequestPost an object receive; wait() returns the object.
isendmethod#
def isend(obj: Any, dest: int, tag: int = 0) -> SerialRequestSend a (pickled) object and return a completed request.
issendmethod#
def issend(obj: Any, dest: int, tag: int = 0) -> SerialRequestSend an object synchronously: complete when a receive takes it.
recvmethod#
def recv(buf: Any = None, source: int = _ANY_SOURCE, tag: int = _ANY_TAG, status: Any = None) -> AnyReturn a received object (None from PROC_NULL).
reducemethod#
def reduce(sendobj: Any, op: Any = None, root: int = 0) -> AnyReturn sendobj.
scanmethod#
def scan(sendobj: Any, op: Any = None) -> AnyReturn sendobj.
scattermethod#
def scatter(sendobj: Any, root: int = 0) -> AnyReturn the only item of sendobj (ValueError unless it has one).
sendmethod#
def send(obj: Any, dest: int, tag: int = 0) -> NoneSend a (pickled) object to dest.
sendrecvmethod#
def sendrecv(sendobj: Any, dest: int, sendtag: int = 0, recvbuf: Any = None, source: int = _ANY_SOURCE, recvtag: int = _ANY_TAG, status: Any = None) -> AnySend sendobj to dest and return the object received from source.
With dest=0, source=0 that is a copy of sendobj (unless an earlier
message matches first); None with source=PROC_NULL.
ssendmethod#
def ssend(obj: Any, dest: int, tag: int = 0) -> NoneSend an object synchronously: a matching receive must be posted.
SerialFileclass#
maybempi._fileView sourceclass SerialFile(handle: Any, path: str, amode: int)Stand-in for mpi4py.MPI.File: a file opened by the only process.
Read_allattributeclass attributeinstance attribute#
Read_all = ReadRead_at_allattributeclass attributeinstance attribute#
Read_at_all = Read_atWrite_allattributeclass attributeinstance attribute#
Write_all = WriteWrite_at_allattributeclass attributeinstance attribute#
Write_at_all = Write_atClosemethod#
def Close() -> NoneClose the file (and delete it with MODE_DELETE_ON_CLOSE).
Deletemethodstaticmethod#
def Delete(filename: str | os.PathLike[str], info: Any = None) -> NoneDelete a file.
Get_amodemethod#
def Get_amode() -> intReturn the access mode the file was opened with.
Get_atomicitymethod#
def Get_atomicity() -> boolReturn the atomicity flag.
Get_byte_offsetmethod#
def Get_byte_offset(offset: int) -> intReturn the byte position of the elementary type at offset in the view.
Get_positionmethod#
def Get_position() -> intReturn the file pointer, in etypes of the view.
Get_sizemethod#
def Get_size() -> intReturn the size of the file in bytes.
Get_viewmethod#
def Get_view() -> tuple[int, _Datatype, _Datatype, str]Return (disp, etype, filetype, datarep).
Ireadmethod#
def Iread(buf: Any) -> AnyRead like Read and return a completed request.
Iread_atmethod#
def Iread_at(offset: int, buf: Any) -> AnyRead like Read_at and return a completed request.
Iwritemethod#
def Iwrite(buf: Any) -> AnyWrite like Write and return a completed request.
Iwrite_atmethod#
def Iwrite_at(offset: int, buf: Any) -> AnyWrite like Write_at and return a completed request.
Openmethodclassmethod#
def Open(comm: Any, filename: str | os.PathLike[str], amode: int = MODE_RDONLY, info: Any = None) -> SerialFileOpen filename with the MPI access mode amode (MODE_RDONLY, …).
Raises
ValueError- For an invalid combination of modes.
OSError- If the file cannot be opened (e.g.
FileNotFoundError).
Preallocatemethod#
def Preallocate(size: int) -> NoneExtend the file to at least size bytes.
Readmethod#
def Read(buf: Any, status: Any = None) -> NoneRead into buf from the file pointer and advance it.
Read_atmethod#
def Read_at(offset: int, buf: Any, status: Any = None) -> NoneRead into buf from the explicit offset offset (in etypes of the view).
Seekmethod#
def Seek(offset: int, whence: int = SEEK_SET) -> NoneMove the file pointer (in etypes of the view).
Raises
ValueError- For
SEEK_ENDin a view with gaps, or a negative position.
Set_atomicitymethod#
def Set_atomicity(flag: bool) -> NoneRecord the atomicity flag (one process is always atomic).
Set_sizemethod#
def Set_size(size: int) -> NoneTruncate or extend the file to size bytes.
Set_viewmethod#
def Set_view(disp: int = 0, etype: _Datatype | None = None, filetype: _Datatype | None = None, datarep: str = 'native', info: Any = None) -> NoneSet the view: data from byte disp on, where filetype places it.
Resets the file pointer to 0.
Raises
ValueError- For a data representation other than
"native", or a file type not built from the elementary type.
Syncmethod#
def Sync() -> NoneWrite the file to the storage device.
Writemethod#
def Write(buf: Any, status: Any = None) -> NoneWrite buf at the file pointer and advance it.
Write_atmethod#
def Write_at(offset: int, buf: Any, status: Any = None) -> NoneWrite buf at the explicit offset offset (in etypes of the view).
SerialGroupclass#
maybempi.serialView sourceclass SerialGroup(size: int = 1)Stand-in for MPI.Group: rank 0 alone, or the empty group.
rankproperty#
rank: intThe rank of this process in the group.
sizeproperty#
size: intThe number of ranks.
Comparemethod#
def Compare(group: SerialGroup) -> intReturn IDENT for groups of the same size, else UNEQUAL.
Differencemethodstaticmethod#
def Difference(group1: SerialGroup, group2: SerialGroup) -> SerialGroupReturn the ranks of group1 that are not in group2.
Dupmethod#
def Dup() -> SerialGroupReturn a copy.
Exclmethod#
def Excl(ranks: Sequence[int]) -> SerialGroupReturn the group without ranks.
Freemethod#
def Free() -> NoneDo nothing.
Get_rankmethod#
def Get_rank() -> intReturn 0, or UNDEFINED for the empty group.
Get_sizemethod#
def Get_size() -> intReturn 1, or 0 for the empty group.
Inclmethod#
def Incl(ranks: Sequence[int]) -> SerialGroupReturn the group of ranks: [0] or [].
Intersectionmethodstaticmethod#
def Intersection(group1: SerialGroup, group2: SerialGroup) -> SerialGroupReturn the intersection of two groups.
Translate_ranksmethod#
def Translate_ranks(ranks: Sequence[int] | None = None, group: SerialGroup | None = None) -> list[int]Return the ranks in group of ranks of this group (0 stays 0).
Unionmethodstaticmethod#
def Union(group1: SerialGroup, group2: SerialGroup) -> SerialGroupReturn the union of two groups.
SerialMPIclass#
maybempi.serialView sourceclass SerialMPIStand-in for the mpi4py.MPI module in a serial run.
:func:~maybempi.launch.get_mpi returns one instance, and
:func:~maybempi.launch.is_serial tells it from mpi4py.MPI.
COMM_WORLD and COMM_SELF are :class:SerialComm objects; the reduction
operations, datatypes and other constants are placeholders that
:class:SerialComm accepts. Is_initialized() is False: MPI itself is
never started.
ANY_SOURCEattributeclass attributeinstance attribute#
ANY_SOURCE = _ANY_SOURCEANY_TAGattributeclass attributeinstance attribute#
ANY_TAG = _ANY_TAGBANDattributeclass attributeinstance attribute#
BAND = _Op('BAND')BOOLattributeclass attributeinstance attribute#
BOOL = _Datatype('BOOL', 1)BORattributeclass attributeinstance attribute#
BOR = _Op('BOR')BOTTOMattributeclass attributeinstance attribute#
BOTTOM = _Constant('BOTTOM')BXORattributeclass attributeinstance attribute#
BXOR = _Op('BXOR')BYTEattributeclass attributeinstance attribute#
BYTE = _Datatype('BYTE', 1)CARTattributeclass attributeinstance attribute#
CART = _CARTCHARattributeclass attributeinstance attribute#
CHAR = _Datatype('CHAR', 1)COMM_NULLattributeclass attributeinstance attribute#
COMM_NULL = _COMM_NULLCOMM_SELFattributeclass attributeinstance attribute#
COMM_SELF = SerialComm('COMM_SELF')COMM_TYPE_SHAREDattributeclass attributeinstance attribute#
COMM_TYPE_SHARED = 0COMM_WORLDattributeclass attributeinstance attribute#
COMM_WORLD = SerialComm('COMM_WORLD')COMPLEXattributeclass attributeinstance attribute#
COMPLEX = _Datatype('COMPLEX', 8)CONGRUENTattributeclass attributeinstance attribute#
CONGRUENT = 1C_BOOLattributeclass attributeinstance attribute#
C_BOOL = _Datatype('C_BOOL', 1)C_DOUBLE_COMPLEXattributeclass attributeinstance attribute#
C_DOUBLE_COMPLEX = _Datatype('C_DOUBLE_COMPLEX', 16)C_FLOAT_COMPLEXattributeclass attributeinstance attribute#
C_FLOAT_COMPLEX = _Datatype('C_FLOAT_COMPLEX', 8)Cartcommattributeclass attributeinstance attribute#
Cartcomm = SerialCartcommCommattributeclass attributeinstance attribute#
Comm = SerialCommDATATYPE_NULLattributeclass attributeinstance attribute#
DATATYPE_NULL = _Null('DATATYPE_NULL')DIST_GRAPHattributeclass attributeinstance attribute#
DIST_GRAPH = _DIST_GRAPHDOUBLEattributeclass attributeinstance attribute#
DOUBLE = _Datatype('DOUBLE', 8)DOUBLE_COMPLEXattributeclass attributeinstance attribute#
DOUBLE_COMPLEX = _Datatype('DOUBLE_COMPLEX', 16)Datatypeattributeclass attributeinstance attribute#
Datatype = _DatatypeFILE_NULLattributeclass attributeinstance attribute#
FILE_NULL = _file.FILE_NULLFLOATattributeclass attributeinstance attribute#
FLOAT = _Datatype('FLOAT', 4)Fileattributeclass attributeinstance attribute#
File = SerialFileGRAPHattributeclass attributeinstance attribute#
GRAPH = _GRAPHGROUP_EMPTYattributeclass attributeinstance attribute#
GROUP_EMPTY = SerialGroup(0)GROUP_NULLattributeclass attributeinstance attribute#
GROUP_NULL = _Null('GROUP_NULL')Groupattributeclass attributeinstance attribute#
Group = SerialGroupIDENTattributeclass attributeinstance attribute#
IDENT = 0INFO_ENVattributeclass attributeinstance attribute#
INFO_ENV = _Constant('INFO_ENV')INFO_NULLattributeclass attributeinstance attribute#
INFO_NULL = _Null('INFO_NULL')INTattributeclass attributeinstance attribute#
INT = _Datatype('INT', ctypes.sizeof(ctypes.c_int))INT16_Tattributeclass attributeinstance attribute#
INT16_T = _Datatype('INT16_T', 2)INT32_Tattributeclass attributeinstance attribute#
INT32_T = _Datatype('INT32_T', 4)INT64_Tattributeclass attributeinstance attribute#
INT64_T = _Datatype('INT64_T', 8)INT8_Tattributeclass attributeinstance attribute#
INT8_T = _Datatype('INT8_T', 1)IN_PLACEattributeclass attributeinstance attribute#
IN_PLACE = _IN_PLACEIntracommattributeclass attributeinstance attribute#
Intracomm = SerialCommLANDattributeclass attributeinstance attribute#
LAND = _Op('LAND')LONGattributeclass attributeinstance attribute#
LONG = _Datatype('LONG', ctypes.sizeof(ctypes.c_long))LONG_DOUBLEattributeclass attributeinstance attribute#
LONG_DOUBLE = _Datatype('LONG_DOUBLE', ctypes.sizeof(ctypes.c_longdouble))LONG_LONGattributeclass attributeinstance attribute#
LONG_LONG = _Datatype('LONG_LONG', 8)LORattributeclass attributeinstance attribute#
LOR = _Op('LOR')LXORattributeclass attributeinstance attribute#
LXOR = _Op('LXOR')MAXattributeclass attributeinstance attribute#
MAX = _Op('MAX')MAXLOCattributeclass attributeinstance attribute#
MAXLOC = _Op('MAXLOC')MINattributeclass attributeinstance attribute#
MIN = _Op('MIN')MINLOCattributeclass attributeinstance attribute#
MINLOC = _Op('MINLOC')MODE_APPENDattributeclass attributeinstance attribute#
MODE_APPEND = _file.MODE_APPENDMODE_CREATEattributeclass attributeinstance attribute#
MODE_CREATE = _file.MODE_CREATEMODE_DELETE_ON_CLOSEattributeclass attributeinstance attribute#
MODE_DELETE_ON_CLOSE = _file.MODE_DELETE_ON_CLOSEMODE_EXCLattributeclass attributeinstance attribute#
MODE_EXCL = _file.MODE_EXCLMODE_RDONLYattributeclass attributeinstance attribute#
MODE_RDONLY = _file.MODE_RDONLYMODE_RDWRattributeclass attributeinstance attribute#
MODE_RDWR = _file.MODE_RDWRMODE_SEQUENTIALattributeclass attributeinstance attribute#
MODE_SEQUENTIAL = _file.MODE_SEQUENTIALMODE_UNIQUE_OPENattributeclass attributeinstance attribute#
MODE_UNIQUE_OPEN = _file.MODE_UNIQUE_OPENMODE_WRONLYattributeclass attributeinstance attribute#
MODE_WRONLY = _file.MODE_WRONLYOP_NULLattributeclass attributeinstance attribute#
OP_NULL = _Null('OP_NULL')ORDER_Cattributeclass attributeinstance attribute#
ORDER_C = ORDER_CORDER_Fattributeclass attributeinstance attribute#
ORDER_F = ORDER_FORDER_FORTRANattributeclass attributeinstance attribute#
ORDER_FORTRAN = ORDER_FOpattributeclass attributeinstance attribute#
Op = _OpPROC_NULLattributeclass attributeinstance attribute#
PROC_NULL = _PROC_NULLPRODattributeclass attributeinstance attribute#
PROD = _Op('PROD')Prequestattributeclass attributeinstance attribute#
Prequest = SerialPrequestREPLACEattributeclass attributeinstance attribute#
REPLACE = _Op('REPLACE')REQUEST_NULLattributeclass attributeinstance attribute#
REQUEST_NULL = _Null('REQUEST_NULL')ROOTattributeclass attributeinstance attribute#
ROOT = -3Requestattributeclass attributeinstance attribute#
Request = SerialRequestSEEK_CURattributeclass attributeinstance attribute#
SEEK_CUR = _file.SEEK_CURSEEK_ENDattributeclass attributeinstance attribute#
SEEK_END = _file.SEEK_ENDSEEK_SETattributeclass attributeinstance attribute#
SEEK_SET = _file.SEEK_SETSIMILARattributeclass attributeinstance attribute#
SIMILAR = 2SUCCESSattributeclass attributeinstance attribute#
SUCCESS = 0SUMattributeclass attributeinstance attribute#
SUM = _Op('SUM')Statusattributeclass attributeinstance attribute#
Status = SerialStatusTHREAD_FUNNELEDattributeclass attributeinstance attribute#
THREAD_FUNNELED = 1THREAD_MULTIPLEattributeclass attributeinstance attribute#
THREAD_MULTIPLE = 3THREAD_SERIALIZEDattributeclass attributeinstance attribute#
THREAD_SERIALIZED = 2THREAD_SINGLEattributeclass attributeinstance attribute#
THREAD_SINGLE = 0UINT16_Tattributeclass attributeinstance attribute#
UINT16_T = _Datatype('UINT16_T', 2)UINT32_Tattributeclass attributeinstance attribute#
UINT32_T = _Datatype('UINT32_T', 4)UINT64_Tattributeclass attributeinstance attribute#
UINT64_T = _Datatype('UINT64_T', 8)UINT8_Tattributeclass attributeinstance attribute#
UINT8_T = _Datatype('UINT8_T', 1)UNDEFINEDattributeclass attributeinstance attribute#
UNDEFINED = _UNDEFINEDUNEQUALattributeclass attributeinstance attribute#
UNEQUAL = 3UNSIGNEDattributeclass attributeinstance attribute#
UNSIGNED = _Datatype('UNSIGNED', ctypes.sizeof(ctypes.c_uint))UNSIGNED_LONGattributeclass attributeinstance attribute#
UNSIGNED_LONG = _Datatype('UNSIGNED_LONG', ctypes.sizeof(ctypes.c_ulong))Compute_dimsmethodstaticmethod#
def Compute_dims(nnodes: int, dims: int | Sequence[int]) -> list[int]Return a process grid for nnodes (1) processes: all ones.
Raises
ValueError- For a number of processes other than 1.
Finalizemethodstaticmethod#
def Finalize() -> NoneDo nothing.
Get_processor_namemethodstaticmethod#
def Get_processor_name() -> strReturn the host name.
Get_versionmethodstaticmethod#
def Get_version() -> tuple[int, int]Return (4, 0): the MPI standard the stand-in follows.
Initmethodstaticmethod#
def Init() -> NoneDo nothing.
Is_finalizedmethodstaticmethod#
def Is_finalized() -> boolReturn False.
Is_initializedmethodstaticmethod#
def Is_initialized() -> boolReturn False: MPI is never started.
Query_threadmethodstaticmethod#
def Query_thread() -> intReturn 0 (THREAD_SINGLE).
Wtickmethodstaticmethod#
def Wtick() -> floatReturn the resolution of :meth:Wtime in seconds.
Wtimemethodstaticmethod#
def Wtime() -> floatReturn the wall-clock time in seconds (time.time()).
SerialPrequestclass#
maybempi.serialView sourceclass SerialPrequest(start: Callable[[], SerialRequest] | None = None)Bases: SerialRequest
A persistent request (Send_init/Recv_init): each Start posts it again.
Before the first Start, the request is inactive and complete.
Cancelmethod#
def Cancel() -> NoneCancel the started operation.
Startmethod#
def Start() -> NonePost the operation (a send or a receive).
Startallmethodstaticmethod#
def Startall(requests: Sequence[Any]) -> NoneStart every request.
Testmethod#
def Test(status: Any = None) -> boolReturn whether the started operation is complete (True if inactive).
Waitmethod#
def Wait(status: Any = None) -> NoneWait for the started operation (at once if inactive).
Inherited from maybempi.serial.SerialRequest
Freemethod#
maybempi.serial.SerialRequestView sourcedef Free() -> NoneDo nothing.
Testallmethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef Testall(requests: Sequence[Any], statuses: Any = None) -> boolReturn whether every request is complete.
Testanymethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef Testany(requests: Sequence[Any], status: Any = None) -> tuple[int, bool]Return (index, True) for a complete request, else (UNDEFINED, ...).
Testsomemethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef Testsome(requests: Sequence[Any], statuses: Any = None) -> list[int] | NoneReturn the indices of the complete requests (None for no requests).
Waitallmethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef Waitall(requests: Sequence[Any], statuses: Any = None) -> NoneWait for every request (RuntimeError if one can never complete).
Waitanymethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef Waitany(requests: Sequence[Any], status: Any = None) -> intReturn the index of a complete request, or UNDEFINED for no requests.
Waitsomemethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef Waitsome(requests: Sequence[Any], statuses: Any = None) -> list[int] | NoneReturn the indices of the complete requests (None for no requests).
testmethod#
maybempi.serial.SerialRequestView sourcedef test(status: Any = None) -> tuple[bool, Any]Return (True, result) when complete, else (False, None).
testallmethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef testall(requests: Sequence[Any], statuses: Any = None) -> tuple[bool, Any]Return (True, results) when all are complete, else (False, None).
waitmethod#
maybempi.serial.SerialRequestView sourcedef wait(status: Any = None) -> AnyReturn the result of the non-blocking object call (RuntimeError if never).
waitallmethodstaticmethod#
maybempi.serial.SerialRequestView sourcedef waitall(requests: Sequence[Any], statuses: Any = None) -> list[Any]Return the results of the requests.
SerialRequestclass#
maybempi.serialView sourceclass SerialRequest(result: Any = None, *, complete: bool = True, waiting_for: str = '')A request of a non-blocking call of :class:SerialComm.
Collectives and sends complete at once. A receive (Irecv, irecv)
or a synchronous send (Issend) completes when its matching message (or
receive) is posted. Waiting for a request that can never complete raises
RuntimeError: on one process, MPI would wait forever.
Cancelmethod#
def Cancel() -> NoneCancel a receive that has no message yet; nothing for a complete request.
Freemethod#
def Free() -> NoneDo nothing.
Testmethod#
def Test(status: Any = None) -> boolReturn whether the operation is complete.
Testallmethodstaticmethod#
def Testall(requests: Sequence[Any], statuses: Any = None) -> boolReturn whether every request is complete.
Testanymethodstaticmethod#
def Testany(requests: Sequence[Any], status: Any = None) -> tuple[int, bool]Return (index, True) for a complete request, else (UNDEFINED, ...).
Testsomemethodstaticmethod#
def Testsome(requests: Sequence[Any], statuses: Any = None) -> list[int] | NoneReturn the indices of the complete requests (None for no requests).
Waitmethod#
def Wait(status: Any = None) -> NoneReturn once the operation is complete (RuntimeError if it never can).
Waitallmethodstaticmethod#
def Waitall(requests: Sequence[Any], statuses: Any = None) -> NoneWait for every request (RuntimeError if one can never complete).
Waitanymethodstaticmethod#
def Waitany(requests: Sequence[Any], status: Any = None) -> intReturn the index of a complete request, or UNDEFINED for no requests.
Waitsomemethodstaticmethod#
def Waitsome(requests: Sequence[Any], statuses: Any = None) -> list[int] | NoneReturn the indices of the complete requests (None for no requests).
testmethod#
def test(status: Any = None) -> tuple[bool, Any]Return (True, result) when complete, else (False, None).
testallmethodstaticmethod#
def testall(requests: Sequence[Any], statuses: Any = None) -> tuple[bool, Any]Return (True, results) when all are complete, else (False, None).
waitmethod#
def wait(status: Any = None) -> AnyReturn the result of the non-blocking object call (RuntimeError if never).
waitallmethodstaticmethod#
def waitall(requests: Sequence[Any], statuses: Any = None) -> list[Any]Return the results of the requests.
SerialStatusclass#
maybempi.serialView sourceclass SerialStatus()Stand-in for MPI.Status: the source, tag and size of a received message.
Get_elementsattributeclass attributeinstance attribute#
Get_elements = Get_countcountattributeinstance attribute#
count = 0errorattributeinstance attribute#
error = 0sourceattributeinstance attribute#
source = 0tagattributeinstance attribute#
tag = 0Get_countmethod#
def Get_count(datatype: Any = None) -> intReturn the number of datatype items received (bytes by default).
Get_errormethod#
def Get_error() -> intReturn 0 (SUCCESS).
Get_sourcemethod#
def Get_source() -> intReturn the source rank (0, or PROC_NULL).
Get_tagmethod#
def Get_tag() -> intReturn the tag of the message.
Is_cancelledmethod#
def Is_cancelled() -> boolReturn False.
get_mpifunction#
maybempi.launchView sourcedef get_mpi(use_mpi: bool | None = None) -> AnyReturn mpi4py.MPI for an MPI run, else the serial stand-in.
Parameters
Returns
Warns
RuntimeWarning- Launched under MPI, but mpi4py is not installed. Every process then runs as if it were alone, as rank 0 of 1.
is_serialfunction#
maybempi.launchView sourcedef is_serial(obj: Any) -> boolTell whether obj is the serial stand-in (the module or a communicator).
Parameters
| Name | Type | Description |
|---|---|---|
obj | Any | What :func:get_mpi returned, or a communicator such as
MPI.COMM_WORLD. |
launched_under_mpifunction#
maybempi.launchView sourcedef launched_under_mpi() -> boolTell whether this process was started by an MPI launcher, without importing mpi4py.
True if a per-rank variable of a common launcher is set (Open MPI, MPICH,
Intel MPI, PMIx/srun, MVAPICH2, Hydra, Cray ALPS/PALS; see
:data:LAUNCHER_VARIABLES), or if mpi4py is already imported and MPI
initialized (using it then costs nothing more). MAYBEMPI=1/0
overrides the detection, e.g. for a launcher whose variables are not known.
Returns
bool- Whether the process belongs to an MPI job.
launcher_variablefunction#
maybempi.launchView sourcedef launcher_variable() -> str | NoneReturn the first variable of :data:LAUNCHER_VARIABLES that is set, if any.
Useful to see why :func:launched_under_mpi decided as it did.
local_rankfunction#
maybempi.launchView sourcedef local_rank() -> intReturn the rank of this process within its node, from the launcher’s environment.
Reads the node-local rank that common launchers export (Open MPI, MVAPICH2,
Intel MPI/MPICH, PMI, Cray PALS, Slurm, LOCAL_RANK, see
:data:LOCAL_RANK_VARIABLES). These are set before MPI_Init, so this works
before MPI is initialized and without importing mpi4py.
Returns
int- The node-local rank, or 0 if no launcher variable is set (a serial run).
set_copy_hookfunction#
maybempi.serialView sourcedef set_copy_hook(hook: Callable[[str, Any], None] | None) -> NoneReport copies between device and host arrays in buffer collectives.
A receive into a host array from a device array (one with .get(), e.g.
a CuPy array), or the other way round, is a transfer that an application
may want to count. The hook is called after each such copy.