I have 2 processes, one process is streaming out packets to another until an internal interrupt halt the process (the process which sends). I want to have a mechanism that the other process can receive until there is any message on this channel to be received.
is there any way to do that other than transferring the halt command as a message as well? I prefer not to send finish/interrupt as another message because there could be scenarios that the interrupt can kill the sender process.
if (world.rank() != 0) {
while (!interrupt())
world.send(ROOT, ID, a, bufferSize);
// I prefer not to send finish/interrupt as another message
}
else {
while (/*there is any packet to be received*/)
world.recv(boost::mpi::any_source, ID, a, bufferSize);
}
If one of the MPI_COMM_WORLD
processes dies, there is no way to properly continue the application. Sending a halt command and keeping the sender alive is absolutely what you should do.
Theoretically, you could use one-sided communication in MPI or a timeout mechanism (using irecv
/ request::cancel
), but I don't see any way this would make sense..