# Module Scientific.MPI

# Submodules:

- Module Scientific.MPI.IO

## Class MPICommunicator: MPI Communicator

There is no constructor for MPI Communicator objects. The default communicator is given by Scientific.MPI.world, and other communicators can only be created by methods on an existing communicator object.

A communicator object has two read-only attributes: `rank` is an integer which indicates the rank of the current process in the communicator, and `size` is an integer equal to the number of processes that participate in the communicator.

Methods:

- duplicate()

  Returns a new communicator object with the same properties as the original one.

- send(data, destination, tag)

  Sends the contents of data (a string or any contiguous NumPy array except for general object arrays) to the processor whose rank is destination, using tag as an identifier.

- nonblockingSend(data, destination, tag)

  Sends the contents of data (a string or any contiguous NumPy array except for general object arrays) to the processor whose rank is destination, using tag as an identifier. The send is nonblocking, i.e. the call returns immediately, even if the destination process is not ready to receive.

  The return value is an MPIRequest object. It is used to wait till the communication has actually happened.

- receive(data, source=`None`, tag=`None`)

  Receives an array from the process with rank source with identifier tag. The default source=None means that messages from any process are accepted. The value of data can either be an array object, in which case it must be contiguous and large enough to store the incoming data; it must also have the correct shape. Alternatively, data can be a string specifying the data type (in practice, one would use Numeric.Int, Numeric.Float, etc.). In the latter case, a new array object is created to receive the data.

  The return value is a tuple containing four elements: the array containing the data, the source process rank (an integer), the message tag (an integer), and the number of elements that were received (an integer).

- receiveString(source=`None`, tag=`None`)

  Receives a string from the process with rank source with identifier tag. The default source=None means that messages from any process are accepted.

  The return value is a tuple containing three elements: the string containing the data, the source process rank (an integer), and the message tag (an integer).

- nonblockingReceive(data, source=`None`, tag=`None`)

  Receives an array from the process with rank source with identifier tag. The default source=None means that messages from any process are accepted. The value of data must be a contiguous array object, large enough to store the incoming data; it must also have the correct shape. Unlike the blocking receive, the size of the array must be known when the call is made, as nonblocking receives of unknown quantities of data is not implemented. For the same reason there is no nonblocking_receiveString.

  The return value is an MPIRequest object. It is used to wait until the data has arrived, and will give information about the size, the source and the tag of the incoming message.

- nonblockingProbe(source=`None`, tag=`None`)

  Checks if a message from the process with rank source and with identifier tag is available for immediate reception. The return value is `None` if no message is available, otherwise a `(source, tag)` tuple is returned.

- broadcast(array, root)

  Sends data from the process with rank root to all processes (including root). The parameter array can be any contiguous NumPy array except for general object arrays. On the process root, it holds the data to be sent. After the call, the data in array is the same for all processors. The shape and data type of array must be the same in all processes.

- share(send, receive)

  Distributes data from each process to all other processes in the communicator. The array send (any contiguous NumPy array except for general object arrays) contains the data to be sent by each process, the shape and data type must be identical in all processes. The array receive must have the same data type as send and one additional dimension (the first one), whose length must be the number of processes in the communicator. After the call, the value of receive[i] is equal to the contents of the array send in process i.

- barrier()

  Waits until all processes in the communicator have called the same method, then all processes continue.

- abort()

  Aborts all processes associated with the communicator. For emergency use only.

- reduce(sendbuffer, receivebuffer, operation, root)

  Combine data from all processes using operation, and send the data to the process identified by root.

  operation is one of the operation objects defined globally in the module: `max`, `min`, `prod`, `sum`, `land`, `lor`, `lxor`, `band`, `bor`, bxor', `maxloc` and `minloc`.

- allreduce(sendbuffer, receivebuffer, operation, root)

  Combine data from all processes using operation, and send the data to all processes in the communicator.

  operation is one of the operation objects defined globally in the module: `max`, `min`, `prod`, `sum`, `land`, `lor`, `lxor`, `band`, `bor`, bxor', `maxloc` and `minloc`.

## Class MPIError: MPI call failed

## Class MPIRequest: MPI Request

There is no constructor for MPI Request objects. They are returned by nonblocking send and receives, and are used to query the status of the message.

Methods:

- wait()

  Waits till the communication has completed. If the operation was a nonblocking send, there is no return value. If the operation was a nonblocking receive, the return value is a tuple containing four elements: the array containing the data, the source process rank (an integer), the message tag (an integer), and the number of elements that were received (an integer).