1. Page Index
  2. 1. Short Description
  3. 2. Syntax
  4. 2.1. C syntax
  5. 2.2. C++ syntax
  6. 3. Parameters
  7. 3.1. Input
  8. 4. Description
  9. 5. Errors
  10. 6. See also

MPI_Send

Short Description

Performs a standard-mode blocking send.

Syntax

C syntax

#include <mpi.h>
int MPI_Send(void *buf, int count, MPI_Datatype datatype,
     int dest, int tag, MPI_Comm comm)

C++ syntax

#include <mpi.h>
void Comm::Send(const void* buf, int count, const Datatype& datatype,
     int dest, int tag) const

Parameters

Input

buf Initial address of send buffer (choice).
count Number of elements send (nonnegative integer).
datatype Datatype of each send buffer element (handle).
dest Rank of destination (integer).
tag Message tag (integer).
comm Communicator (handle).

Description

MPI_Send performs a standard-mode, blocking send. This means that until the message has been actually written to the output buffer, the sender cannot continue running the program.

Imagen MPI_send (Click on the image to watch the animation)

An easy code of how to use it:

int main(int argc, char *argv[])
{
    int rank, size;
 
    MPI_Init(&argc, &argv); // We start the processes communication data
    MPI_Comm_size(MPI_COMM_WORLD, &size); // We get the total of processes
    MPI_Comm_rank(MPI_COMM_WORLD, &rank); // We get the rank of this process
 
    MPI_Send(&rank // reference to send data
    		,1 // number of elements we are sending
    		,MPI_INT // Datatype of each element
    		,rank+1 // Rank of destination process
    		,0 // tag
    		,MPI_COMM_WORLD); // Communicator used
    .
    .
    .
    MPI_Finalize();
    return 0;
}

Errors

MPI_SUCCESS No error; MPI routine completed successfully.
MPI_ERR_COMM Invalid communicator. A common error is to use a null communicator in a call (not even allowed in MPI_Comm_rank).
MPI_ERR_COUNT Invalid count argument. Count arguments must be non-negative; a count of zero is often valid.
MPI_ERR_TYPE Invalid datatype argument. May be an uncommitted MPI_Datatype (see MPI_Type_commit).
MPI_ERR_TAG Invalid tag argument. Tags must be non-negative; tags in a receive (MPI_Recv, MPI_Irecv, MPI_Sendrecv, etc.) may also be MPI_ANY_TAG. The largest tag value is available through the the attribute MPI_TAG_UB.
MPI_ERR_RANK Invalid source or destination rank. Ranks must be between zero and the size of the communicator minus one; ranks in a receive (MPI_Recv, MPI_Irecv, MPI_Sendrecv, etc.) may also be MPI_ANY_SOURCE.

See also

MPI_Isend

Created by: Daniel Guerrero Martínez y Sergio Rodríguez Lumley 2010

Valid HTML 4.01 Transitional