I want to stop immediately an MPI program, that has N processors and each processor runs a different algorithm (with different computational complexities). Processors share information to each other using an unidirectional token ring topology. As soon as one processor ends it should notify its neighbor and all processors should stop immediately as soon as they receive the interruption. Here is an sketch of the execution program at each processor:
1. Processor_i(array of n data) {
2. while (stopping condition is not satisfied) {
3. Run algorithm_i(data) for the ith processor
4. Receive information from its source node (at most read 2 messages)
5. if (the incomming message indicates interruption)
6. break;
7. Send its own information to its destiny node (maximum 2 messages)
8. }
9. Save local solution
10. Send interruption message to its destiny node
11. }
Notice that in the step 3, the computational complexity may be, for example, O(n^2), O(n log n) or O(n^3) for processors 1, 2 and 3, respectively.
My problem is that the messages are buffering by MPI and the interruption message is not reading immediately. I was thinking in writing a file with the stopping instruction, but the filesystem is not shared.
How could I deal with this problem?