[mpiwg-tools] Tool question about handling requests in completion calls

Joachim Protze protze at itc.rwth-aachen.de
Fri Aug 20 03:51:52 CDT 2021

Hi all,

Marc-Andre pointed me to MPI_Request_get_status during yesterday's call.
The plan for next week's call is to talk about any/some/all versions of
this call.

Here is how I would use the function in test calls:

int MPI_Test(MPI_Request* req, int* flag, MPI_Status* status){​​​​​​​​​​​​​
  int ret = PMPI_Request_get_status(*req, flag, status);
    // tool code to handle the successful test
    PMPI_Test(req, flag, MPI_STATUS_IGNORE);
  return ret;

int MPI_Testsome(int incount, MPI_Request req[], int* outcount, int*
indices, MPI_Status* statuses[]){
  int ret = PMPI_Request_get_status_some(incount, req, outcount,
indices, statuses), flag;
  for(int i=0; i < *outcount; i++){
    // tool code to handle the successful test on req[indices[i]]
    PMPI_Test(req[indices[i]], &flag, MPI_STATUS_IGNORE);
  return ret;

int MPI_Testany(int count, MPI_Request req[], int* index, int* flag,
MPI_Status* status){
  int ret = PMPI_Request_get_status_any(count, req, index, flag, statuses);
    // tool code to handle the successful test on req[index]
    PMPI_Test(req[index], &flag, MPI_STATUS_IGNORE);
  return ret;

int MPI_Testall(int count, MPI_Request req[], int* flag, MPI_Status*
  int ret = PMPI_Request_get_status_all(count, req, flag, statuses);
    // tool code to handle the successful test on all req
    PMPI_Testall(req, &flag, MPI_STATUSES_IGNORE);
  return ret;

However, I'm not convinced that I'll like to use a similar approach for

int MPI_Waitall(int count, MPI_Request req[], MPI_Status* statuses[]){
  int flag;
    int ret = PMPI_Request_get_status_all(incount, req, &flag, statuses);
  } while(!flag);
  // tool code to handle the successful test on all req
  PMPI_Testall(req, &flag, MPI_STATUSES_IGNORE);
  return ret;


Am 12.08.21 um 16:23 schrieb Joachim Protze via mpiwg-tools:
> Hi all,
> working on a tool, I'm wondering whether someone has a better solution
> than copying the whole array before calling the PMPI function.
> In the tool, we want to observe the lifetime of requests and
> semantically bind information to the request handle (e.g.
> std::map<MPI_Request, tool_info*>).
> When we observe completion of the request, the request handle passed by
> the application is already reset to MPI_REQUEST_NULL and cannot be used
> for the lookup. So, we need to copy the whole array of requests in order
> to lookup the information for the request after the PMPI call.
> For a call like MPI_Testany, this means to copy /count/ values to
> possibly use one of the values.
> Is there any chance to improve the situation? Would it be possible to
> bind the request handle to the status object for reference?
> It is clear that the request handle is invalid at that moment, but could
> still be used for some lookup.
> Alternatively, it would help to bind an info(?) object to the request
> handle, which moves to the status on completion.
> Best
> Joachim
> _______________________________________________
> mpiwg-tools mailing list
> mpiwg-tools at lists.mpi-forum.org
> https://lists.mpi-forum.org/mailman/listinfo/mpiwg-tools

Dipl.-Inf. Joachim Protze

IT Center
Group: High Performance Computing
Division: Computational Science and Engineering
RWTH Aachen University
Seffenter Weg 23
D 52074  Aachen (Germany)
Tel: +49 241 80- 24765
Fax: +49 241 80-624765
protze at itc.rwth-aachen.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-tools/attachments/20210820/f4b4c9bc/attachment.p7s>

More information about the mpiwg-tools mailing list