首页 > 解决方案 > Is MPI_COMM_WORLD not constant?

问题描述

I read here, that

While MPI_Comm_split is the most common communicator creation function, there are many others. MPI_Comm_dup is the most basic and creates a duplicate of a communicator. It may seem odd that there would exist a function that only creates a copy, but this is very useful for applications which use libraries to perform specialized functions, such as mathematical libraries. In these kinds of applications, it’s important that user codes and library codes do not interfere with each other. To avoid this, the first thing every application should do is to create a duplicate of MPI_COMM_WORLD, which will avoid the problem of other libraries also using MPI_COMM_WORLD. The libraries themselves should also make duplicates of MPI_COMM_WORLD to avoid the same problem.

Can MPI_COMM_WORLD be changed after the start of the initialisation of MPI? Is MPI_COMM_WORLD not constant?

标签: cparallel-processingmpicommunicator

解决方案


理由MPI_Comm_dup(MPI_COMM_WORLD, ...)是您不希望 MPI 应用程序 (in MPI_COMM_WORLD) 发送的消息被底层库接收。相反,您不希望 MPI 应用程序接收库发送的消息。

避免这种情况的一种简单方法是为库使用专用的通信器,而复制MPI_COMM_WORLD是实现这一目标的最简单方法。

您的问题的答案是MPI_COMM_WORLD之后无法更改MPI_Init()。更一般地说,通信器一旦创建就不能更改。


推荐阅读