Newsgroups: comp.parallel.mpi
From: raja@rsn.hp.com (Raja Daoud)
Subject: Re: Multiple TAG in Recv.
Organization: Hewlett-Packard Co.
Date: 18 May 1998 15:58:19 -0500
Message-ID: <6jq7db$gls@tbag.rsn.hp.com>

Gregory Zeleny  <unspecified@gs.com> wrote:
>Recv(0,0,MPI_ANY_SOURCE, TAG1|TAG2, &status, MPI_COMM_WORLD)

One approach is to use two MPI_Irecv() requests and block on MPI_Waitany():

	MPI_Request	reqs[2];
	MPI_Status	status;

	MPI_Irecv(..., MPI_ANY_SOURCE, TAG1, MPI_COMM_WORLD, &reqs[0]);
	MPI_Irecv(..., MPI_ANY_SOURCE, TAG2, MPI_COMM_WORLD, &reqs[1]);

	while (...) {
		MPI_Waitany(2, reqs, &index, &status);

		if (index == 0) {
			/* got TAG1 message */
		} else {
			/* got TAG2 message */
		}
/*
 * Re-issue the completed recv request.
 */
		MPI_Irecv(..., MPI_ANY_SOURCE, (index == 0) ? TAG1 : TAG2,
				MPI_COMM_WORLD, &reqs[index]);
	}

Regards,

--Raja

-=-
Raja Daoud				Hewlett-Packard Co.
raja@rsn.hp.com				http://www.hp.com/go/mpi

