c++ - 当接收方不发布接收时标准和非阻塞发送会发生什么

标签 c++ mpi openmpi

如果我使用 MPI_SendMPI_Isend 发送,而接收进程要么没有接收死机要么太忙无法回复怎么办?

我怎么知道我应该停止发送到进程,因为它没有接收/死或忙

我试过 1:

MPI_Send (&destNode, strlen(destNode)+1, MPI_CHAR, nameServer, TAG_NAME_RESOLUTION, MPI_COMM_WORLD, &req);

然而,当 nameServer 不是接收模式时,发送是阻塞的

我尝试了 2 使用 MPI_Isend 并测试是否发送了 msg:

    //Ask nameServer (process 1) to resolve destNode 
    MPI_Isend (&destNode, strlen(destNode)+1, MPI_CHAR, nameServer, TAG_NAME_RESOLUTION, MPI_COMM_WORLD, &req);

    int flag = 0;
    MPI_Test(&req, &flag,  &stat);

但是,即使我知道 MPI_Send 由于进程未接收而挂起,我仍然收到 flag = 1

最佳答案

MPI_Send 返回或 MPI_Isend 请求是否完成 (flag==true) 不一定取决于匹配的接收发布。在这两种情况下,它只意味着发送缓冲区可以被重用。

虽然条件相似,但您的 MPI 实现可能只决定在一种情况下进行缓冲,而在另一种情况下不进行缓冲。或者它可能会在周三的满月期间缓冲。你不能对此做出任何假设。

如果出于某种原因需要函数返回或操作完成来指示消息实际收到,则需要使用同步模式调用,即 MPI_SsendMPI_Issend.

引用MPI_Send (3.4) 的标准

The send call described in Section 3.2.1 uses the standard communication mode. In this mode, it is up to MPI to decide whether outgoing messages will be buffered. MPI may buffer outgoing messages. In such a case, the send call may complete before a matching receive is invoked. On the other hand, buffer space may be unavailable, or MPI may choose not to buffer outgoing messages, for performance reasons. In this case, the send call will not complete until a matching receive has been posted, and the data has been moved to the receiver.

如果您希望确保您的程序可以继续,尽管没有收到消息,您可以继续使用 MPI_Isend 并确保在 指示完成之前不会触及缓冲区和请求MPI_Test.

对于MPI_Isend/MPI_Test (3.7.3)

The completion of a send operation indicates that the sender is now free to update the locations in the send buffer (the send operation itself leaves the content of the send buffer unchanged). It does not indicate that the message has been received, rather, it may have been buffered by the communication subsystem.

附言如果您的接收器等级已失效,那么您的 MPI 程序很可能是不正确的。

关于c++ - 当接收方不发布接收时标准和非阻塞发送会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53067665/

相关文章:

c - MPI_Waitall 无效请求

openmpi - 我是否使用 OpenMPI 或 MPICH 进行编译?

c++ - 可以在 Internet 上而不是在 LAN 集群内分发 MPI (C++) 程序吗?

c++ - fork/pipes 和运行多个程序

c++ - 将 libsndfile 库链接到 Code::Blocks on Windows

c++ - 修改 map 中包含的类的正确方法是什么?

c - MPI Communicator MPI_Comm_split 无组

c++ - g++/clang 超快速解析但不是编译模式?

c++ - MPI:Waitany 对 ibcast 调用没有反应

c - 使用 openMPI 发送 gmp 类型 mpf_t