mpi4py.MPI.Comm

class mpi4py.MPI.Comm(comm=None)

Bases: object

Communicator

Parameters

comm (Optional[Comm]) –

Return type

Comm

static __new__(cls, comm=None)
Parameters

comm (Optional[Comm]) –

Return type

Comm

Methods Summary

Abort([errorcode])

Terminate MPI execution environment

Allgather(sendbuf, recvbuf)

Gather to All, gather data from all processes and distribute it to all other processes in a group

Allgatherv(sendbuf, recvbuf)

Gather to All Vector, gather data from all processes and distribute it to all other processes in a group providing different amount of data and displacements

Allreduce(sendbuf, recvbuf[, op])

Reduce to All

Alltoall(sendbuf, recvbuf)

All to All Scatter/Gather, send data from all to all processes in a group

Alltoallv(sendbuf, recvbuf)

All to All Scatter/Gather Vector, send data from all to all processes in a group providing different amount of data and displacements

Alltoallw(sendbuf, recvbuf)

Generalized All-to-All communication allowing different counts, displacements and datatypes for each partner

Barrier()

Barrier synchronization

Bcast(buf[, root])

Broadcast a message from one process to all other processes in a group

Bsend(buf, dest[, tag])

Blocking send in buffered mode

Bsend_init(buf, dest[, tag])

Persistent request for a send in buffered mode

Call_errhandler(errorcode)

Call the error handler installed on a communicator

Clone()

Clone an existing communicator

Compare(comm1, comm2)

Compare two communicators

Create(group)

Create communicator from group

Create_group(group[, tag])

Create communicator from group

Create_keyval([copy_fn, delete_fn, nopython])

Create a new attribute key for communicators

Delete_attr(keyval)

Delete attribute value associated with a key

Disconnect()

Disconnect from a communicator

Dup([info])

Duplicate an existing communicator

Dup_with_info(info)

Duplicate an existing communicator

Free()

Free a communicator

Free_keyval(keyval)

Free an attribute key for communicators

Gather(sendbuf, recvbuf[, root])

Gather together values from a group of processes

Gatherv(sendbuf, recvbuf[, root])

Gather Vector, gather data to one process from all other processes in a group providing different amount of data and displacements at the receiving sides

Get_attr(keyval)

Retrieve attribute value by key

Get_errhandler()

Get the error handler for a communicator

Get_group()

Access the group associated with a communicator

Get_info()

Return the hints for a communicator that are currently in use

Get_name()

Get the print name for this communicator

Get_parent()

Return the parent intercommunicator for this process

Get_rank()

Return the rank of this process in a communicator

Get_size()

Return the number of processes in a communicator

Get_topology()

Determine the type of topology (if any) associated with a communicator

Iallgather(sendbuf, recvbuf)

Nonblocking Gather to All

Iallgatherv(sendbuf, recvbuf)

Nonblocking Gather to All Vector

Iallreduce(sendbuf, recvbuf[, op])

Nonblocking Reduce to All

Ialltoall(sendbuf, recvbuf)

Nonblocking All to All Scatter/Gather

Ialltoallv(sendbuf, recvbuf)

Nonblocking All to All Scatter/Gather Vector

Ialltoallw(sendbuf, recvbuf)

Nonblocking Generalized All-to-All

Ibarrier()

Nonblocking Barrier

Ibcast(buf[, root])

Nonblocking Broadcast

Ibsend(buf, dest[, tag])

Nonblocking send in buffered mode

Idup()

Nonblocking duplicate an existing communicator

Igather(sendbuf, recvbuf[, root])

Nonblocking Gather

Igatherv(sendbuf, recvbuf[, root])

Nonblocking Gather Vector

Improbe([source, tag, status])

Nonblocking test for a matched message

Iprobe([source, tag, status])

Nonblocking test for a message

Irecv(buf[, source, tag])

Nonblocking receive

Ireduce(sendbuf, recvbuf[, op, root])

Nonblocking Reduce to Root

Ireduce_scatter(sendbuf, recvbuf[, ...])

Nonblocking Reduce-Scatter (vector version)

Ireduce_scatter_block(sendbuf, recvbuf[, op])

Nonblocking Reduce-Scatter Block (regular, non-vector version)

Irsend(buf, dest[, tag])

Nonblocking send in ready mode

Is_inter()

Test to see if a comm is an intercommunicator

Is_intra()

Test to see if a comm is an intracommunicator

Iscatter(sendbuf, recvbuf[, root])

Nonblocking Scatter

Iscatterv(sendbuf, recvbuf[, root])

Nonblocking Scatter Vector

Isend(buf, dest[, tag])

Nonblocking send

Issend(buf, dest[, tag])

Nonblocking send in synchronous mode

Join(fd)

Create a intercommunicator by joining two processes connected by a socket

Mprobe([source, tag, status])

Blocking test for a matched message

Probe([source, tag, status])

Blocking test for a message

Recv(buf[, source, tag, status])

Blocking receive

Recv_init(buf[, source, tag])

Create a persistent request for a receive

Reduce(sendbuf, recvbuf[, op, root])

Reduce to Root

Reduce_scatter(sendbuf, recvbuf[, ...])

Reduce-Scatter (vector version)

Reduce_scatter_block(sendbuf, recvbuf[, op])

Reduce-Scatter Block (regular, non-vector version)

Rsend(buf, dest[, tag])

Blocking send in ready mode

Rsend_init(buf, dest[, tag])

Persistent request for a send in ready mode

Scatter(sendbuf, recvbuf[, root])

Scatter data from one process to all other processes in a group

Scatterv(sendbuf, recvbuf[, root])

Scatter Vector, scatter data from one process to all other processes in a group providing different amount of data and displacements at the sending side

Send(buf, dest[, tag])

Blocking send

Send_init(buf, dest[, tag])

Create a persistent request for a standard send

Sendrecv(sendbuf, dest[, sendtag, recvbuf, ...])

Send and receive a message

Sendrecv_replace(buf, dest[, sendtag, ...])

Send and receive a message

Set_attr(keyval, attrval)

Store attribute value associated with a key

Set_errhandler(errhandler)

Set the error handler for a communicator

Set_info(info)

Set new values for the hints associated with a communicator

Set_name(name)

Set the print name for this communicator

Split([color, key])

Split communicator by color and key

Split_type(split_type[, key, info])

Split communicator by split type

Ssend(buf, dest[, tag])

Blocking send in synchronous mode

Ssend_init(buf, dest[, tag])

Persistent request for a send in synchronous mode

allgather(sendobj)

Gather to All

allreduce(sendobj[, op])

Reduce to All

alltoall(sendobj)

All to All Scatter/Gather

barrier()

Barrier synchronization

bcast(obj[, root])

Broadcast

bsend(obj, dest[, tag])

Send in buffered mode

f2py(arg)

gather(sendobj[, root])

Gather

ibsend(obj, dest[, tag])

Nonblocking send in buffered mode

improbe([source, tag, status])

Nonblocking test for a matched message

iprobe([source, tag, status])

Nonblocking test for a message

irecv([buf, source, tag])

Nonblocking receive

isend(obj, dest[, tag])

Nonblocking send

issend(obj, dest[, tag])

Nonblocking send in synchronous mode

mprobe([source, tag, status])

Blocking test for a matched message

probe([source, tag, status])

Blocking test for a message

py2f()

recv([buf, source, tag, status])

Receive

reduce(sendobj[, op, root])

Reduce to Root

scatter(sendobj[, root])

Scatter

send(obj, dest[, tag])

Send

sendrecv(sendobj, dest[, sendtag, recvbuf, ...])

Send and Receive

ssend(obj, dest[, tag])

Send in synchronous mode

Attributes Summary

group

communicator group

info

communicator info

is_inter

is intercommunicator

is_intra

is intracommunicator

is_topo

is a topology communicator

name

communicator name

rank

rank of this process in communicator

size

number of processes in communicator

topology

communicator topology type

Methods Documentation

Abort(errorcode=0)

Terminate MPI execution environment

Warning

This is a direct call, use it with care!!!.

Parameters

errorcode (int) –

Return type

NoReturn

Allgather(sendbuf, recvbuf)

Gather to All, gather data from all processes and distribute it to all other processes in a group

Parameters
Return type

None

Allgatherv(sendbuf, recvbuf)

Gather to All Vector, gather data from all processes and distribute it to all other processes in a group providing different amount of data and displacements

Parameters
Return type

None

Allreduce(sendbuf, recvbuf, op=SUM)

Reduce to All

Parameters
Return type

None

Alltoall(sendbuf, recvbuf)

All to All Scatter/Gather, send data from all to all processes in a group

Parameters
Return type

None

Alltoallv(sendbuf, recvbuf)

All to All Scatter/Gather Vector, send data from all to all processes in a group providing different amount of data and displacements

Parameters
Return type

None

Alltoallw(sendbuf, recvbuf)

Generalized All-to-All communication allowing different counts, displacements and datatypes for each partner

Parameters
Return type

None

Barrier()

Barrier synchronization

Return type

None

Bcast(buf, root=0)

Broadcast a message from one process to all other processes in a group

Parameters
Return type

None

Bsend(buf, dest, tag=0)

Blocking send in buffered mode

Parameters
Return type

None

Bsend_init(buf, dest, tag=0)

Persistent request for a send in buffered mode

Parameters
Return type

Request

Call_errhandler(errorcode)

Call the error handler installed on a communicator

Parameters

errorcode (int) –

Return type

None

Clone()

Clone an existing communicator

Return type

Comm

classmethod Compare(comm1, comm2)

Compare two communicators

Parameters
Return type

int

Create(group)

Create communicator from group

Parameters

group (Group) –

Return type

Comm

Create_group(group, tag=0)

Create communicator from group

Parameters
Return type

Comm

classmethod Create_keyval(copy_fn=None, delete_fn=None, nopython=False)

Create a new attribute key for communicators

Parameters
  • copy_fn (Optional[Callable[[Comm, int, Any], Any]]) –

  • delete_fn (Optional[Callable[[Comm, int, Any], None]]) –

  • nopython (bool) –

Return type

int

Delete_attr(keyval)

Delete attribute value associated with a key

Parameters

keyval (int) –

Return type

None

Disconnect()

Disconnect from a communicator

Return type

None

Dup(info=None)

Duplicate an existing communicator

Parameters

info (Optional[Info]) –

Return type

Comm

Dup_with_info(info)

Duplicate an existing communicator

Parameters

info (Info) –

Return type

Comm

Free()

Free a communicator

Return type

None

classmethod Free_keyval(keyval)

Free an attribute key for communicators

Parameters

keyval (int) –

Return type

int

Gather(sendbuf, recvbuf, root=0)

Gather together values from a group of processes

Parameters
Return type

None

Gatherv(sendbuf, recvbuf, root=0)

Gather Vector, gather data to one process from all other processes in a group providing different amount of data and displacements at the receiving sides

Parameters
Return type

None

Get_attr(keyval)

Retrieve attribute value by key

Parameters

keyval (int) –

Return type

Optional[Union[int, Any]]

Get_errhandler()

Get the error handler for a communicator

Return type

Errhandler

Get_group()

Access the group associated with a communicator

Return type

Group

Get_info()

Return the hints for a communicator that are currently in use

Return type

Info

Get_name()

Get the print name for this communicator

Return type

str

classmethod Get_parent()

Return the parent intercommunicator for this process

Return type

Intercomm

Get_rank()

Return the rank of this process in a communicator

Return type

int

Get_size()

Return the number of processes in a communicator

Return type

int

Get_topology()

Determine the type of topology (if any) associated with a communicator

Return type

int

Iallgather(sendbuf, recvbuf)

Nonblocking Gather to All

Parameters
Return type

Request

Iallgatherv(sendbuf, recvbuf)

Nonblocking Gather to All Vector

Parameters
Return type

Request

Iallreduce(sendbuf, recvbuf, op=SUM)

Nonblocking Reduce to All

Parameters
Return type

Request

Ialltoall(sendbuf, recvbuf)

Nonblocking All to All Scatter/Gather

Parameters
Return type

Request

Ialltoallv(sendbuf, recvbuf)

Nonblocking All to All Scatter/Gather Vector

Parameters
Return type

Request

Ialltoallw(sendbuf, recvbuf)

Nonblocking Generalized All-to-All

Parameters
Return type

Request

Ibarrier()

Nonblocking Barrier

Return type

Request

Ibcast(buf, root=0)

Nonblocking Broadcast

Parameters
Return type

Request

Ibsend(buf, dest, tag=0)

Nonblocking send in buffered mode

Parameters
Return type

Request

Idup()

Nonblocking duplicate an existing communicator

Igather(sendbuf, recvbuf, root=0)

Nonblocking Gather

Parameters
Return type

Request

Igatherv(sendbuf, recvbuf, root=0)

Nonblocking Gather Vector

Parameters
Return type

Request

Improbe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Nonblocking test for a matched message

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

Optional[Message]

Iprobe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Nonblocking test for a message

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

bool

Irecv(buf, source=ANY_SOURCE, tag=ANY_TAG)

Nonblocking receive

Parameters
Return type

Request

Ireduce(sendbuf, recvbuf, op=SUM, root=0)

Nonblocking Reduce to Root

Parameters
Return type

Request

Ireduce_scatter(sendbuf, recvbuf, recvcounts=None, op=SUM)

Nonblocking Reduce-Scatter (vector version)

Parameters
Return type

Request

Ireduce_scatter_block(sendbuf, recvbuf, op=SUM)

Nonblocking Reduce-Scatter Block (regular, non-vector version)

Parameters
Return type

Request

Irsend(buf, dest, tag=0)

Nonblocking send in ready mode

Parameters
Return type

Request

Is_inter()

Test to see if a comm is an intercommunicator

Return type

bool

Is_intra()

Test to see if a comm is an intracommunicator

Return type

bool

Iscatter(sendbuf, recvbuf, root=0)

Nonblocking Scatter

Parameters
Return type

Request

Iscatterv(sendbuf, recvbuf, root=0)

Nonblocking Scatter Vector

Parameters
Return type

Request

Isend(buf, dest, tag=0)

Nonblocking send

Parameters
Return type

Request

Issend(buf, dest, tag=0)

Nonblocking send in synchronous mode

Parameters
Return type

Request

classmethod Join(fd)

Create a intercommunicator by joining two processes connected by a socket

Parameters

fd (int) –

Return type

Intercomm

Mprobe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Blocking test for a matched message

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

Message

Probe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Blocking test for a message

Note

This function blocks until the message arrives.

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

Literal[True]

Recv(buf, source=ANY_SOURCE, tag=ANY_TAG, status=None)

Blocking receive

Note

This function blocks until the message is received

Parameters
Return type

None

Recv_init(buf, source=ANY_SOURCE, tag=ANY_TAG)

Create a persistent request for a receive

Parameters
Return type

Prequest

Reduce(sendbuf, recvbuf, op=SUM, root=0)

Reduce to Root

Parameters
Return type

None

Reduce_scatter(sendbuf, recvbuf, recvcounts=None, op=SUM)

Reduce-Scatter (vector version)

Parameters
Return type

None

Reduce_scatter_block(sendbuf, recvbuf, op=SUM)

Reduce-Scatter Block (regular, non-vector version)

Parameters
Return type

None

Rsend(buf, dest, tag=0)

Blocking send in ready mode

Parameters
Return type

None

Rsend_init(buf, dest, tag=0)

Persistent request for a send in ready mode

Parameters
Return type

Request

Scatter(sendbuf, recvbuf, root=0)

Scatter data from one process to all other processes in a group

Parameters
Return type

None

Scatterv(sendbuf, recvbuf, root=0)

Scatter Vector, scatter data from one process to all other processes in a group providing different amount of data and displacements at the sending side

Parameters
Return type

None

Send(buf, dest, tag=0)

Blocking send

Note

This function may block until the message is received. Whether or not Send blocks depends on several factors and is implementation dependent

Parameters
Return type

None

Send_init(buf, dest, tag=0)

Create a persistent request for a standard send

Parameters
Return type

Prequest

Sendrecv(sendbuf, dest, sendtag=0, recvbuf=None, source=ANY_SOURCE, recvtag=ANY_TAG, status=None)

Send and receive a message

Note

This function is guaranteed not to deadlock in situations where pairs of blocking sends and receives may deadlock.

Caution

A common mistake when using this function is to mismatch the tags with the source and destination ranks, which can result in deadlock.

Parameters
Return type

None

Sendrecv_replace(buf, dest, sendtag=0, source=ANY_SOURCE, recvtag=ANY_TAG, status=None)

Send and receive a message

Note

This function is guaranteed not to deadlock in situations where pairs of blocking sends and receives may deadlock.

Caution

A common mistake when using this function is to mismatch the tags with the source and destination ranks, which can result in deadlock.

Parameters
Return type

None

Set_attr(keyval, attrval)

Store attribute value associated with a key

Parameters
  • keyval (int) –

  • attrval (Any) –

Return type

None

Set_errhandler(errhandler)

Set the error handler for a communicator

Parameters

errhandler (Errhandler) –

Return type

None

Set_info(info)

Set new values for the hints associated with a communicator

Parameters

info (Info) –

Return type

None

Set_name(name)

Set the print name for this communicator

Parameters

name (str) –

Return type

None

Split(color=0, key=0)

Split communicator by color and key

Parameters
  • color (int) –

  • key (int) –

Return type

Comm

Split_type(split_type, key=0, info=INFO_NULL)

Split communicator by split type

Parameters
  • split_type (int) –

  • key (int) –

  • info (Info) –

Return type

Comm

Ssend(buf, dest, tag=0)

Blocking send in synchronous mode

Parameters
Return type

None

Ssend_init(buf, dest, tag=0)

Persistent request for a send in synchronous mode

Parameters
Return type

Request

allgather(sendobj)

Gather to All

Parameters

sendobj (Any) –

Return type

List[Any]

allreduce(sendobj, op=SUM)

Reduce to All

Parameters
  • sendobj (Any) –

  • op (Union[Op, Callable[[Any, Any], Any]]) –

Return type

Any

alltoall(sendobj)

All to All Scatter/Gather

Parameters

sendobj (Sequence[Any]) –

Return type

List[Any]

barrier()

Barrier synchronization

Note

This method is equivalent to Comm.Barrier()

Return type

None

bcast(obj, root=0)

Broadcast

Parameters
  • obj (Any) –

  • root (int) –

Return type

Any

bsend(obj, dest, tag=0)

Send in buffered mode

Parameters
  • obj (Any) –

  • dest (int) –

  • tag (int) –

Return type

None

classmethod f2py(arg)
Parameters

arg (int) –

Return type

Comm

gather(sendobj, root=0)

Gather

Parameters
  • sendobj (Any) –

  • root (int) –

Return type

Optional[List[Any]]

ibsend(obj, dest, tag=0)

Nonblocking send in buffered mode

Parameters
  • obj (Any) –

  • dest (int) –

  • tag (int) –

Return type

Request

improbe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Nonblocking test for a matched message

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

Optional[Message]

iprobe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Nonblocking test for a message

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

bool

irecv(buf=None, source=ANY_SOURCE, tag=ANY_TAG)

Nonblocking receive

Parameters
Return type

Request

isend(obj, dest, tag=0)

Nonblocking send

Parameters
  • obj (Any) –

  • dest (int) –

  • tag (int) –

Return type

Request

issend(obj, dest, tag=0)

Nonblocking send in synchronous mode

Parameters
  • obj (Any) –

  • dest (int) –

  • tag (int) –

Return type

Request

mprobe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Blocking test for a matched message

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

Message

probe(source=ANY_SOURCE, tag=ANY_TAG, status=None)

Blocking test for a message

Parameters
  • source (int) –

  • tag (int) –

  • status (Optional[Status]) –

Return type

Literal[True]

py2f()
Return type

int

recv(buf=None, source=ANY_SOURCE, tag=ANY_TAG, status=None)

Receive

Parameters
Return type

Any

reduce(sendobj, op=SUM, root=0)

Reduce to Root

Parameters
  • sendobj (Any) –

  • op (Union[Op, Callable[[Any, Any], Any]]) –

  • root (int) –

Return type

Optional[Any]

scatter(sendobj, root=0)

Scatter

Parameters
  • sendobj (Sequence[Any]) –

  • root (int) –

Return type

Any

send(obj, dest, tag=0)

Send

Parameters
  • obj (Any) –

  • dest (int) –

  • tag (int) –

Return type

None

sendrecv(sendobj, dest, sendtag=0, recvbuf=None, source=ANY_SOURCE, recvtag=ANY_TAG, status=None)

Send and Receive

Parameters
  • sendobj (Any) –

  • dest (int) –

  • sendtag (int) –

  • recvbuf (Optional[Buffer]) –

  • source (int) –

  • recvtag (int) –

  • status (Optional[Status]) –

Return type

Any

ssend(obj, dest, tag=0)

Send in synchronous mode

Parameters
  • obj (Any) –

  • dest (int) –

  • tag (int) –

Return type

None

Attributes Documentation

group

communicator group

info

communicator info

is_inter

is intercommunicator

is_intra

is intracommunicator

is_topo

is a topology communicator

name

communicator name

rank

rank of this process in communicator

size

number of processes in communicator

topology

communicator topology type