我在使用 MPI 时遇到了一个非常奇怪的错误。无法删除成功创建的通讯器。删除尝试会在所有节点上导致 FATAL ERROR,但通信器组中包含的节点除外。最小的工作示例如下。您如何看待这种奇怪行为的原因?
#include <stdio.h>
#include <mpi.h>
int main(int argc, char* argv[])
{
MPI_Group group_world; // group of MPI_COMM_WORLD
MPI_Group group_new; // new group
MPI_Comm comm_new; // new communicator
int group_new_ranks[3]={10,20,30}; // new communicator's ranks
MPI_Init(&argc, &argv);
MPI_Comm_group(MPI_COMM_WORLD, &group_world); // get group_world - MPI_SUCCESS for all nodes
MPI_Group_incl(group_world, 3, group_new_ranks, &group_new); // get new group - MPI_SUCCESS for all nodes
MPI_Comm_create(MPI_COMM_WORLD, group_new, &comm_new); // create new communicator - MPI_SUCCESS for all nodes
MPI_Comm_free(&comm_new); // FATAL ERROR for all nodes except 10, 20, 30
MPI_Group_free(&group_new);
MPI_Group_free(&group_world);
MPI_Finalize();
return 0;
}