For my MPI application, each process reads a file and for each line sends a message
(MPI_Send) to one of the other processes determined by the contents of that line. Each
process posts a single MPI_Irecv and uses MPI_Request_get_status to test for a received
message. If a message has been received, it processes the message and posts a new
MPI_Irecv. I believe this situation is not safe and prone to deadlock since MPI_Send may
block. The receiver would need to post as many MPI_Irecv as messages it expects to
receive, but it does not know in advance how many messages to expect from the other
processes. How is this situation usually handled in an MPI appliation where the number of
messages to receive is unknown?
In a non-MPI network program I would create one thread for receiving and processing, and
one thread for transmitting. Is threading a good solution? Is there a simpler solution?
Under what conditions will MPI_Send block and under what conditions will it definitely not