Syntax: MPI Point to Point Communication

MPI Point to Point Communication Calls
C and Fortran Syntax


Blocking Sends

  • Argument Definitions

    IN = provided by programmer, OUT = set by routine

    buf: starting address of message buffer (IN)
    count: number of elements in message (IN)
    datatype: type of elements in message (IN)
    dest: rank of destination task in communicator comm (IN)
    tag: message tag (IN)
    comm: communicator (IN)
    ierror: error code (OUT)

     

  • Blocking Synchronous Send

    C

    int MPI_Ssend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)

    Fortran

    MPI_Ssend (buf, count, datatype, dest, tag, comm, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, ierror

     

  • Blocking Ready Send

    C

    int MPI_Rsend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)

    Fortran

    MPI_Rsend (buf, count, datatype, dest, tag, comm, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, ierror

     

  • Blocking Buffered Send

    C

    int MPI_Bsend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)

    Fortran

    MPI_Bsend (buf, count, datatype, dest, tag, comm, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, ierror

     

  • Blocking Standard Send

    C

    int MPI_Send (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)

    Fortran

    MPI_Send (buf, count, datatype, dest, tag, comm, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, ierror

     


Blocking Receive

  • Argument Definitions

    IN = provided by programmer, OUT = set by routine

    buf: starting address of message buffer (OUT-buffer contents written)
    count: number of elements in message (IN)
    datatype: type of elements in message (IN)
    source: rank of source task in communicator comm (IN)
    tag: message tag (IN)
    comm: communicator (IN)
    status: status of communication event (OUT)
    ierror: error code (OUT)

     

  • C

    int MPI_Recv (void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status status)

     

  • Fortran

    MPI_Recv (buf, count, datatype, source, tag, comm, status, ierror)
    <type> buf(*)
    integer count, datatype, source, tag, comm, status(MPI_STATUS_SIZE), ierror


Non-blocking Sends

  • Argument Definitions

    IN = provided by programmer, OUT = set by routine

    buf: starting address of message buffer (IN)
    count: number of elements in message (IN)
    datatype: type of elements in message (IN)
    dest: rank of destination task in communicator comm (IN)
    tag: message tag (IN)
    comm: communicator (IN)
    request: identifies a communication event (OUT)
    ierror: error code (OUT)

     

  • Non-blocking Synchronous Send

    C

    int MPI_Issend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)

    Fortran

    MPI_Issend (buf, count, datatype, dest, tag, comm, request, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, request, ierror

     

  • Non-blocking Ready Send

    C

    int MPI_Irsend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)

    Fortran

    MPI_Irsend (buf, count, datatype, dest, tag, comm, request, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, request, ierror

     

  • Non-blocking Buffered Send

    C

    int MPI_Ibsend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)

    Fortran

    MPI_Ibsend (buf, count, datatype, dest, tag, comm, request, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, request, ierror

     

  • Non-blocking Standard Send

    C

    int MPI_Isend (void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request)

    Fortran

    MPI_Isend (buf, count, datatype, dest, tag, comm, request, ierror)
    <type> buf(*)
    integer count, datatype, dest, tag, comm, request, ierror

     


Non-blocking Receive

  • Argument Definitions

    IN = provided by programmer, OUT = set by routine

    buf: starting address of message buffer (OUT-buffer contents written)
    count: number of elements in message (IN)
    datatype: type of elements in message (IN)
    source: rank of source task in communicator comm (IN)
    tag: message tag (IN)
    comm: communicator (IN)
    request: identifies a communication event (OUT)
    ierror: error code (OUT)

     

  • C

    int MPI_Irecv (void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request)

     

  • Fortran

    MPI_Irecv (buf, count, datatype, source, tag, comm, request, ierror)
    <type> buf(*)
    integer count, datatype, source, tag, comm, request, ierror


Managing the User-Supplied Buffer

 

  • Attaching the Buffer

    Argument Definitions

    buf: starting address of user-supplied buffer (IN)
    size: number of bytes in user supplied buffer (IN)
    ierror: error code (OUT)

    C

    int MPI_Buffer_attach (void* buf, int size)

    Fortran

    MPI_Buffer_attach (buf, size, ierror)
    <type> buf(*)
    integer size, ierror

     

  • Detaching the Buffer

    Argument Definitions

    buf: starting address of user-supplied buffer (OUT)
    size: number of bytes in user supplied buffer (OUT)
    ierror: error code (OUT)

    C

    int MPI_Buffer_detach (void** buf, int* size)

    Fortran

    MPI_Buffer_detach (buf, size, ierror)
    <type> buf(*)
    integer size, ierror


Checking for Completion, Blocking

  • Argument Definitions

    request: identifies a communication event (INOUT)
    status: status of communication event (OUT)
    count: number of communication events (IN)
    index: index in array of requests of completed event (OUT)
    incount: number of communication events (IN)
    outcount: number of completed events (OUT)
    ierror: error code (OUT)

     

  • C

    int MPI_Wait (MPI_Request *request, MPI_Status *status)

    int MPI_Waitall (int count, MPI_Request *array_of_requests, MPI_Status *array_of_statuses)

    int MPI_Waitany (int count, MPI_Request *array_of_requests, int *index, MPI_Status *status)

    int MPI_Waitsome (int incount, MPI_Request *array_of_requests, int *outcount, int* array_of_indices, MPI_Status *array_of_statuses)

     

  • Fortran

    MPI_Wait (request, status, ierror)
    integer request, status(MPI_STATUS_SIZE), ierror

    MPI_Waitall (count, array_of_requests, array_of_statuses, ierror)
    integer count, array_of_requests(*), array_of_statuses(MPI_STATUS_SIZE,*), ierror

    MPI_Waitany (count, array_of_requests, index, status, ierror)
    integer count, array_of_requests(*), index, status(MPI_STATUS_SIZE), ierror

    MPI_Waitsome (incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierror)
    integer incount, array_of_requests(*), outcount, array_of_indices(*), array_of_statuses(MPI_STATUS_SIZE,*), ierror


Checking for Completion, Non-Blocking

  • Argument Definitions

    request: identifies a communication event (INOUT)
    flag: TRUE if communication event has completed (OUT)
    status: status of communication event (OUT)
    count: number of communication events (IN)
    index: index in array of requests of completed event (OUT)
    incount: number of communication events (IN)
    outcount: number of completed events (OUT)
    ierror: error code (OUT)

     

  • C

    int MPI_Test (MPI_Request *request, int *flag, MPI_Status *status)

    int MPI_Testall (int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_statuses)

    int MPI_Testany (int count, MPI_Request *array_of_requests, int *index, int *flag, MPI_Status *status)

    int MPI_Testsome (int incount, MPI_Request *array_of_requests, int *outcount, int* array_of_indices, MPI_Status *array_of_statuses)

     

  • Fortran

    MPI_Test (request, flag, status, ierror)
    integer request, status(MPI_STATUS_SIZE), ierror
    logical flag

    MPI_Testall (count, array_of_requests, flag, array_of_statuses, ierror)
    integer count, array_of_requests(*), array_of_statuses(MPI_STATUS_SIZE,*), ierror
    logical flag

    MPI_Testany (count, array_of_requests, index, flag, status, ierror)
    integer count, array_of_requests(*), index, status(MPI_STATUS_SIZE), ierror
    logical flag

    MPI_Testsome (incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierror)
    integer incount, array_of_requests(*), outcount, array_of_indices(*), array_of_statuses(MPI_STATUS_SIZE,*), ierror


Miscellaneous

  • Combined Send/Recv

    Argument Definitions

    sendbuf: starting address of send buffer (IN)
    sendcount: number of elements in outgoing message (IN)
    sendtype: type of elements in outgoing message (IN)
    dest: rank in communicator of destination task (IN)
    sendtag: message tag for outgoing communication (IN)
    recvbuf: starting address of receive buffer (OUT-buffer contents written)
    recvcount: number of elements in incoming message (IN)
    recvtype: type of elements in incoming message (IN)
    source: rank in communicator of source task (IN)
    recvtag: message tag for incoming communication (IN)
    comm: communicator (IN)
    status: status of communication event (OUT)
    buf: starting address of send and receive buffers (INOUT)
    ierror: error code (OUT)

    C

    int MPI_Sendrecv (void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm, MPI_Status *status)

    int MPI_Sendrecv_replace (void *buf, int count, MPI_Datatype datatype, int dest, int sendtag, int source, int recvtag, MPI_Comm comm, MPI_Status *status)

    Fortran

    MPI_Sendrecv (sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm, status, ierror)
    <type> sendbuf(*), recvbuf(*)
    integer sendcount, sendtype, dest, sendtag, recvcount, recvtype, source, recvtag, comm, status(MPI_STATUS_SIZE), ierror

    MPI_Sendrecv_replace (buf, count, datatype, dest, sendtag, source, recvtag, comm, status, ierror)
    <type> buf(*)
    integer count, datatype, dest, sendtag, source, recvtag, comm, status(MPI_STATUS_SIZE), ierror

     

  • Probe

    Argument Definitions

    source: rank of source task in communicator comm (IN)
    tag: message tag (IN)
    comm: communicator (IN)
    status: status of communication event (OUT)
    flag: TRUE if communication event has completed (OUT)
    ierror: error code (OUT)

    C

    int MPI_Probe (int source, int tag, MPI_Comm comm, MPI_Status *status)

    int MPI_Iprobe (int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status)

    Fortran

    MPI_Probe (source, tag, comm, status, ierror)
    integer source, tag, comm, status(MPI_STATUS_SIZE), ierror

    MPI_Iprobe (source, tag, comm, flag, status, ierror)
    integer source, tag, comm, status(MPI_STATUS_SIZE), ierror
    logical flag

     

  • Status parameters

    FORTRAN C ------- -

    source: status(MPI_SOURCE) status.MPI_SOURCE

    tag: status(MPI_TAG) status.MPI_TAG

    error: status(MPI_ERROR) status.MPI_ERROR

     

  • Learn the number of elements

    Argument Definitions

    status: status of communication event (IN)
    count: number of elements in message (OUT)
    datatype: type of elements in message (IN)

    C

    int MPI_Get_count (MPI_Status *status, MPI_Datatype datatype, int *count)

    Fortran

    MPI_Get_count (status, datatype, count, ierror)
    integer status(MPI_STATUS_SIZE), datatype, count, ierror


References

Gropp, W., Lusk, E. and Skjellum, A. (1994) Using MPI. Portable Parallel Programming with the Message-Passing Interface. The MIT Press. Cambridge, Massachusetts.

Message Passing Interface Forum (1995) MPI: A Message Passing Interface Standard. June 12, 1995. Available in postscript from http://www.epm.ornl.gov/~walker/mpi