My program needs Process 0 to keep incrementing a counter and send messages until it receives a message from the last process in the program, which then have Process 0 decrement the same counter and send messages. I don’t know how to "Listen"/Poll whether a message has been received
My Case: (i is counter)
While Process 0 Has not received 0 from process 1, i++ and send message.
After Process 0 received the message, i– and send message.
Or in a more general sense:
While Process 0 has not received message from process 1, do A
After Process 0 has received the message from process 1, do B
How do I do this in MPI?
Thanks Alot!
Generally, you would use
MPI_Isend,MPI_Irecv, andMPI_Testfor polling. Read your book’s chapters on nonblocking communication.