我想立即停止一个 MPI 程序,它有 N 个处理器,每个处理器运行不同的算法(具有不同的计算复杂度)。处理器使用单向令牌环拓扑相互共享信息。一旦一个处理器结束,它应该通知它的邻居,并且所有处理器都应该在收到中断后立即停止。这是每个处理器的执行程序的草图:
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. }
请注意,在步骤 3 中,例如,处理器 1、2 和 3 的计算复杂度可能分别为 O(n^2)、O(n log n) 或 O(n^3)。
我的问题是消息由 MPI 缓冲,并且中断消息没有立即读取。我正在考虑使用停止指令编写文件,但文件系统未共享。
我该如何处理这个问题?