Performs a standard-mode blocking send.
#include <mpi.h> int MPI_Send(void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
#include <mpi.h> void Comm::Send(const void* buf, int count, const Datatype& datatype, int dest, int tag) const
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). |
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.
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; }
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. |