MPI_COMM_WORLD 不是常数吗?

Is MPI_COMM_WORLD not constant?

我读了here,那个

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.

MPI_COMM_WORLD可以在MPI初始化开始后更改吗? MPI_COMM_WORLD不是常数吗?

MPI_Comm_dup(MPI_COMM_WORLD, ...) 的理由是您不希望 MPI 应用程序发送的消息(在 MPI_COMM_WORLD 中)被图书馆接收在幕后.相反,您不希望 MPI 应用程序接收图书馆发送的消息。

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

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