Comparing: Point-to-point communication



Sending point-to-point messages in PVM

Sending a message in PVM involves three steps.

Initializing the SEND buffer

The routine pvmfinitsend(encoding, bufid) clears the default send buffer and prepares it for packing a new message. encoding: integer specifying the next message's encoding scheme. bufid: integer returned containing the message buffer identifier. Values less than zero indicate an error.


Packing the SEND buffer

The routine pvmfpack(what, xp, nitem, stride, info) packs an array of a given data type into the active send buffer.
	what:	integer specifying the type of data being packed.
	xp:	Pointer to the beginning of a block of bytes.
	nitem:	The total number of items to be packed.
	stride:	The stride to be used when packing items.
	info:	Integer status code returned by routine.  Values 
		less than zero indicate an error. 

Sending messages

The routine pvmfsend(tid,msgtag,info) sends a message stored in the active buffer to the PVM process identified by tid.
	tid:	task indentifier of destination process.
	msgtag:	integer message tag supplied by the user.
	info:	integer status code returned by the routine.

Receiving point-to-point messages in PVM

Receiving a message involves two steps.

Point-to-point communication MPI

All MPI communications require a communicator argument and MPI processes can only communicate if they share a communicator.

A communicator in simple terms comprises a process group, context, and other attributes.

A group is a list of processes. The processes are ordered and numbered consecutively from 0, the number of each process is its rank.

To send a message a source process makes an MPI call that specifies the rank of the destination process. The destination process must make a corresponding MPI call to receive the message.


Communication modes in MPI

There are four communication modes provided by MPI: These modes refer to the types of send and it is not meaningful to talk of communication in the context of receive.

An example of a SEND call

The example chosen is that of a Standard send.

The routine is called as follows:

	   MPI_SEND(BUF,COUNT,DATATYPE, DEST,  TAG, COMM, IERROR)
	where:
	   BUF      is the address of the data to be sent.
	   COUNT    is the number of MPI datatype elements in BUF.
	   DATATYPE is the MPI datatype, e.g. MPI_INTEGER,
		    MPI_REAL.
	   DEST     is the destination for the message, given as 
		    the rank within the group associated with the 
		    communicator COMM. 
	   TAG      is a marker used by the programmer to
		    distinguish messages.
	   COMM     is the communicator  shared by the sending 
		    and receiving processes.  Only processes
		    sharing a communicator can communicate.
	   IERROR   contains the return value of the Fortran 
		    version of the standard send.

An example of a RECEIVE call

The example chosen is that of a blocking receive.

The routine is called as follows:

	   MPI_RECV(BUF,COUNT,DATATYPE,SOURCE,TAG,COMM,STATUS,IERROR)
	where:
	   BUF      is the address where the data should be
		    placed once received.
	   COUNT    is the number of elements of a certain
		    MPI datatype that BUF can contain.
	   DATATYPE is the MPI datatype for the message.
	   SOURCE   is the rank of the source of the message
		    in the group associated with the 
		    communicator COMM.
	   TAG      is used by the receiving process to
		    prescribe that it should receive a
		    message with a certain tag.
	   COMM     is the communicator specified by both 
		    sending and receiving processes.
	   STATUS   may be used as an argument to other MPI
		    routines eg to find the number of
		    elements actually received.
	   IERROR   contains the return value of the Fortran
		    version of the standard receive.

PREVIOUS NEXT
UP


Submitted by Mark Johnston,
last updated on 10 December 1994.