Everything is the title. My team and I are currently working on a project and we are using MPI. In one place, we are doing a MPI_send resquesting for a resource with a timeout. If the resource is available, we return 1 and if not and the timeout ended, we return 0. We tried using the signals like SIGALRM, but it doesn't work because every new request cancel the old ones by setting a new alarm.
Thanks for your answer !!
You should investigate the non-blocking point-to-point communication primitives such as MPI_Isend
, MPI_Irecv
and MPI_Iprobe
. You can then implement the timeout yourself, and use MPI_Cancel
if you wish.
There is no standard way to accomplish this.
Implementing the send/recv pair with non-blocking calls (e.g. MPI_Isend, MPI_Irecv) and using MPI_Test and MPI_Cancel is one possible solution.
Depending on the nature of the nature of the resource, and the number of times in the program this functionality is required, you might also consider implementing the MPI_ISend as a "persistent request" object. There is more information here: Persistent Communications.
The advantage of a persistent request is that the request can be formed, and then only executed if the resource is actually available....assuming that the resource can be checked independently of the actual MPI_* call. The persistent communication request can be re-used many times throughout the program, without needing to reform the entire MPI_Send/MPI_Recv call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With