I have a MPI program where the master node waits until certain number of tasks (say 1000) are completed by slave nodes. The slave nodes are in a while(True) loop and keep on generating output from their tasks. The runtime of these tasks can vary across tasks and nodes, so if there are 2 slave nodes and the master needs to wait for say 1000 tasks then slave-node-1 could have completed 450 tasks, and slave-node-2 the other 550.
What is the best way for the slave nodes to "tell" the master node that in total 1000 tasks have been completed ? It looks to me that I need some sort of a shared queue across processes where slaves can push data once their task is completed, and the master just polls on this queue's size until it hits 1000. Subsequently, the master can drain data from this queue to reset the queue size for slaves to fill in more data.
MPI_ANY_SOURCE
if there should be some imbalance between processes. – Gilles Gouaillardet