Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPI reuse MPI_Request

Tags:

mpi

hpc

Is it safe to re-use a finished MPI_Request for another request ? I have been using a pool of MPI_Request to improve performance and there is no error. But it would be good to know for sure.

like image 349
w00d Avatar asked Jan 11 '23 00:01

w00d


2 Answers

Variables of type MPI_Request are not request objects themselves but rather just opaque handles (something like an abstract pointer) to the real MPI request objects. Assigning a new value to such a variable in no way affects the MPI object and only breaks the association to it. Therefore the object might become inaccessible in the sense that if no handle to it exists in your program, it can no longer be passed to MPI calls. This is the same as losing a pointer to a dynamically allocated memory block, thus leaking it.

When it comes to asynchronous request handles, once the operation is completed, MPI destroys the request object and MPI_Wait* / MPI_Test* set the passed handle variable to MPI_REQUEST_NULL on return. Also, a call to MPI_Request_free will mark the request for deletion and set the handle to MPI_REQUEST_NULL on return. At that point you can reuse the variable and store a different request handle in it.

The same applies to handles to communicators (of type MPI_Comm), handles to datatypes (of type MPI_Datatype), handles to reduce operations (of type MPI_Op), and so on.

like image 123
Hristo Iliev Avatar answered Apr 28 '23 12:04

Hristo Iliev


It's just fine to reuse your MPI_Request objects as long as they're completed before you use them again (either by completing the request or freeing the request object manually using MPI_REQUEST_FREE).

like image 42
Wesley Bland Avatar answered Apr 28 '23 13:04

Wesley Bland