mpi - MPI 的一个非常奇怪的行为

标签 mpi

我在使用 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;
}

最佳答案

MPI_Comm_create()MPI_COMM_NULL返回给不在组内的所有进程。您正在将 MPI_COMM_NULL 传递给 MPI_Comm_free() ,这是不允许的。

关于mpi - MPI 的一个非常奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12649302/

相关文章:

c - MPI_Recv 期间 MPI 程序卡住

c - MPI_Irecv 类型转换需要错误

C、MPI : Program not terminating and not printing numbers

c++ - 如何在 MPI 中使用多维 STL vector

c++ - 并行程序编译错误

mpi - GPU可以在CPU的多个核心之间共享吗?

compiler-errors - 设置代码::Blocks to compile MPI programs with MPICC.exe

c++ - mpi MPI_Send() 适用于小数据集但不适用于大数据集

c++ - MPI_Reduce 选择前 k 个结果

c - Mpi函数定义