当接收方未 post 接收时,标准和非阻塞发送会发生什么
What happens for standard and non-blocking sends when the receiver does not post a receive
如果我使用 MPI_Send
或 MPI_Isend
发送,而接收进程要么没有接收死机,要么太忙无法回复怎么办?
我怎么知道我应该停止发送到进程,因为它不是 receiving/dead 或忙碌
我试过1次:
MPI_Send (&destNode, strlen(destNode)+1, MPI_CHAR, nameServer, TAG_NAME_RESOLUTION, MPI_COMM_WORLD, &req);
然而,当 nameServer
不是接收模式时,发送是阻塞的
我使用 MPI_Isend
尝试了 2 并测试是否发送了消息:
//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
return 或 MPI_Isend
请求是否完成 (flag==true
) 不一定取决于正在发布的匹配接收。在这两种情况下,都只意味着发送缓冲区可以被重用。
虽然条件相似,但您的 MPI 实现可能只决定在一种情况下进行缓冲,而在另一种情况下不进行缓冲。或者它可能会在周三的满月期间缓冲。你不能假设任何事情。
如果您出于某种原因需要函数 return 或操作完成来指示消息已实际收到,您需要使用同步模式调用,即 MPI_Ssend
或 MPI_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
并确保在 [=17= 指示完成之前不会触及缓冲区和请求].
对于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.
P.S。如果您的接收器等级是 dead,那么您的 MPI 程序很可能是不正确的。
如果我使用 MPI_Send
或 MPI_Isend
发送,而接收进程要么没有接收死机,要么太忙无法回复怎么办?
我怎么知道我应该停止发送到进程,因为它不是 receiving/dead 或忙碌
我试过1次:
MPI_Send (&destNode, strlen(destNode)+1, MPI_CHAR, nameServer, TAG_NAME_RESOLUTION, MPI_COMM_WORLD, &req);
然而,当 nameServer
不是接收模式时,发送是阻塞的
我使用 MPI_Isend
尝试了 2 并测试是否发送了消息:
//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
return 或 MPI_Isend
请求是否完成 (flag==true
) 不一定取决于正在发布的匹配接收。在这两种情况下,都只意味着发送缓冲区可以被重用。
虽然条件相似,但您的 MPI 实现可能只决定在一种情况下进行缓冲,而在另一种情况下不进行缓冲。或者它可能会在周三的满月期间缓冲。你不能假设任何事情。
如果您出于某种原因需要函数 return 或操作完成来指示消息已实际收到,您需要使用同步模式调用,即 MPI_Ssend
或 MPI_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
并确保在 [=17= 指示完成之前不会触及缓冲区和请求].
对于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.
P.S。如果您的接收器等级是 dead,那么您的 MPI 程序很可能是不正确的。