Ok, the title sounds confusing but the concept is not too bad. Basically, I have two processes that are running (let's call them process 0 and process 1). They both run a function at the same time. While this function is running, sometimes they need data from each other. So process 0 sometimes requests data from process 1 and vice versa. Since they rely on each other, I don't want one process to finish before the other. If process 0 finishes its work, it should continue checking for requests from process 1 (otherwise process 1 won't be able to finish). After both processes have finished their work, only then should they proceed.
I'm having trouble implementing this. Right now, I have each process send all other processes a notification when it finishes (so process 1 sends a notification to process 2 when its work is done). Then I have a loop that is supposed to continue until it receives a notification from all the other processes. Only then should the loop exit and the process continue. However, this isn't working. The processes keep going before the others have finished. I feel like there's probably a much simpler way to do this that I'm not thinking of.
I'm a complete newbie to MPI, so I hope I've explained this properly. Also, this needs to work for any number of processes, not just two. Thanks for your help!