next up previous contents
Next: Send Semantics Up: Sending and Receiving Messages Previous: Message Buffer Memory Model   Contents


Sending

In the spirit of malloc(), the user must call a function to allocate an outgoing message. At the time of allocation, the user must declare not only the size of the message but its destination and tag. The user may then store data in this memory area, and notify the library when it is ready to be sent. After sending the message, the user is not longer permitted to access the message buffer (Figure 1).

Figure 1: Allocating and sending a message in C
\begin{figure}\begin{verbatim}...
INTEGER*4 message(2)message(0)=10
mess...
...1)=20
CALL AP_BSEND(message,2*4,destination,tag)
...\end{verbatim}\end{figure}

In Fortran, there is no way to access a message buffer allocated by the library, so it is not possible to have separate calls for message allocation and sending. Fortran is provided with a single routine AP_BSEND() to perform the allocation, copy the data from a Fortran variable to the message buffer, and send the message (Figure 2).

Figure 2: Sending a message in Fortran
\begin{figure}\begin{verbatim}...
int *ret_msg;if (AP_recv(MPI_ANY_SOURCE...
...n'',ret_msg[0],ret_msg[1]);
AP_free(ret_msg);
}
...\end{verbatim}\end{figure}


next up previous contents
Next: Send Semantics Up: Sending and Receiving Messages Previous: Message Buffer Memory Model   Contents
Raymond Loy 2000-05-12