MPI_Probe return 尽快吗?

Does MPI_Probe return as soon as possible?

假设我的 MPI 进程正在等待一个非常大的消息,而我正在等待 MPI_Probe。假设 MPI_Probe 调用将 return 一旦进程收到来自网络的消息的第一个通知(例如具有大小的 header 或类似的东西)是否正确?

也就是说,它 return 会比我用 MPI_Recv 等待消息快得多吗,因为它不需要接收完整的消息?

该标准在这个问题上相当沉默(MPI-3.0,第 3.8.1 节),但确实提供了:

The MPI implementation of MPI_PROBE and MPI_IPROBE needs to guarantee progress: if a call to MPI_PROBE has been issued by a process, and a send that matches the probe has been initiated by some process, then the call to MPI_PROBE will return, unless the message is received by another concurrent receive operation (that is executed by another thread at the probing process).

由于MPI_PROBE 和MPI_RECV 都会使用进度引擎,我怀疑这两个函数之间除了内存复制之外有什么不同。通过使用进度引擎,MPI 实现很可能会(在内部)接收消息。在MPI_PROBE中可以避免将其复制到用户缓冲区的最后一步。

如果您担心性能,那么尽可能避免 MPI_ANY_SOURCE 和 MPI_ANY_TAG 将有助于大多数实现(当然是 MPICH)采取更快的路径。