使用MPI,在C中,当且仅当我在主进程ID 0中收到来自N个处理器的所有数据时,如何执行函数?
编辑:是否有一种方法可以按照与发送时相同的顺序接收所有数据?
答案 0 :(得分:1)
如果我正确地提出您的问题MPI_Reduce就是您所需要的。
编辑:所以我没有正确地回答你的问题。你需要的是MPI_Gather。在本文档中,您会看到:Each process (root process included) sends the contents of its send buffer to the root process. The root process receives the messages and stores them in rank order.
希望这能回答您的问题。
答案 1 :(得分:1)
尝试查看MPI_Gather功能。在调用之后,您可以通过以下方式检查条件执行:
if (ierr == MPI_SUCCESS) {
// Execute a function
}