next up previous contents
Next: Asynchronous Reductions Up: Sending and Receiving Messages Previous: Send Semantics   Contents


Receiving

On the receiving side, the user calls AP_recv() giving criteria for the message it wishes to receive. Flags may be specified to select various options such as blocking. Memory is automatically allocated to receive messages from MPI. If a message is available that matches the user's criteria, a pointer into the library's storage area is returned. When the user is done examining the contents of the message, a call to the library notifies it that the space may be reclaimed (Figure 3).

Figure 3: Receiving and freeing a message in C
\begin{figure}\begin{verbatim}...
int *message;message= (int *)AP_alloc(d...
...message[0]=10;
message[1]=20;
AP_send(message);
...\end{verbatim}\end{figure}

In Fortran, the AP_RECV() routine is unable to pass back a pointer to the received message. Instead, it returns an integer descriptor. Once the user code has examined the tag and size, and decided which Fortran variable to store the message in, this descriptor is given to AP_COPY_FREE() to copy the message there and free the library's buffer (Figure 4).

Figure 4: Receiving and freeing a message in Fortran
\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}


next up previous contents
Next: Asynchronous Reductions Up: Sending and Receiving Messages Previous: Send Semantics   Contents
Raymond Loy 2000-05-12