Subject: Suggestions of S R Chapple on section 3.7.5.

From: Marc Snir <[email-masked]>
Date: Wed, 13 Jul 1994 14:17:47 -0400

:-) :-) :-) *** (-: (-: (-:

I got some time ago a note from S R Chapple that points at some
problems in the definition of the behavior of
MPI_{TEST|WAIT}{ |ANY|SOME|ALL} when supplied with a list of handles that are
all null or inactive (there is no debate about the "normal" behavior of these
functions.)

Let's call this situation, for short, "empty list".  Let's call the status that
signals no message (tag = MPI_ANY_TAG, source = MPI_ANY_SOURCE, count = 0) the
"null status".

The changes Chapple suggests:

1. TEST and TESTANY should return flag = TRUE on an empty list (rather than
current flag = FALSE).  In addition, TEST will return a null status (currently,
it does not set the status).

Note that TESTANY will return index = MPI_UNDEFINED on an empty list.

Thus, for TEST flag=TRUE and status = 'null' indicates that there is no pending
communication to wait; flag=TRUE and status != 'null' indicates that a
communication completed; and flag = FALSE indicates that the communication has
not complete.

For TESTANY, flag = FALSE inidcates that no communication completed; flag =
TRUE and index = MPI_UNDEFINED will indicate that there is no communication
to wait for; and flag = TRUE and index != MPI_UNDEFINED will indicate that a
communication completed.

Reasons for change:
Need to distinguish TESTANY returning (with flag = FALSE, index =
MPI_UNDEFINED) because none of the pending communications completed,
and TESTANY returning (now with flag = TRUE, index = MPI_UNDEFINED)
because there is no communication to complete.

Similarly, need to distinguish TEST returning (with flag = FALSE) because the
pending communication has not completed, and TEST returning (now with
flag = TRUE, status = "null") because there is no pending communication.

With the change, busy waiting on list of communications would go like

while(1) {
   /* busy wait until flag=1 */
   while (!{MPI_Testany(count, reqs, &idx, &flag, &status); flag}) ;
   if(idx == MPI_UNDEFINED) break; /* no more requests */
   do_something(reqs, &idx, &status); /* else handle completed
communication*/
   }

2.  WAITSOME and TESTSOME should return outcount = MPI_UNDEFINED on an empty
list (rather than outcount = 0).

Reason for change:
Need to distinguish TESTSOME returning (with outcount = 0) because no
communication has completed, and TESTSOME returning (with outcount =
MPI_UNDEFINED) because there is no operation to complete.  WAITSOME is modified
in order to be consistent with TESTSOME.

Thus, a loop that deals for all communications in a list could be written as

while(1) {
   MPI_Waitsome(incnt, reqs, &outcnt, indxs, statuses);
   if (outcnt == MPI_UNDEFINED) break;
   for(i=0; i<outcnt; i++) do_something(reqs[indxs[i]],statuses[indxs[i]]);
   }

Same will work with WAITSOME replace by TESTSOME.

After this change, the overall logic of these operations on an empty input is
as follows:

1. TEST{ |ANY|SOME} returns immediatly, with flag = TRUE.

2. Operations that can complete only part of the requests in the list, namely
{WAIT | TEST}{ANY | SOME} will return an MPI_UNDEFINED value in the index {ANY}
or outcount {SOME} that specifies the
completed request(s), to indicate there was no request to complete.

3. The other operations, namely {TEST | WAIT}{ | ALL}, set the status
of all requests that where invalid/inactive to the "null status".

I agree with these changes -- they simplify the design and make it more
consistent and useful. Also, the changes are quite minor.  However, this is a
clear departure from the current text, motivated by useability considerations,
that will need approval by the forum.

Comments?

---

From: [email-masked] (Cherri Pancake)
Date: Tue, 19 Jul 94 16:13:29 PDT

I agree that the suggested change would improve the precision with which 
the TEST/etc. functions can be used.

As per Marc's second note, I think the changes are substantive and must go to
the larger forum for review.

Cherri Pancake