MPI:主从程序中的分段故障

时间:2017-10-01 09:10:22

标签: c++ mpi mpich

以下是一个简单的程序,其中所有Slaves进程都向Master进程发送消息。

执行时的程序有时会正确运行并引发Segmentation Fault其他程序。

int token;

if(rank == 0)
{
    for (int irank = 1; irank < world_size; irank++)
    {
        MPI_Recv(&token, 1, MPI_INT, irank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
        cout << "Master: Token = " << token << endl;
    }
}


if(rank != 0)
{
    token = 1;
    cout << "Slave: Token = " << token << endl;
    MPI_Send(&token, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
}

Full code here

以下是错误消息:

YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault:
11 (signal 11) This typically refers to a problem with your
application. Please see the FAQ page for debugging suggestions

Full Error here

为什么会这样?这是由于通信延迟吗?如果是,我该如何解决?

0 个答案:

没有答案