MPI: Segmentation fault in Master Slave Program

帅比萌擦擦* 提交于 2020-01-07 04:25:15

问题


Following is a simple program where all Slaves process sends a message to the Master process.

The program when executed runs correctly sometimes and raises Segmentation Faultthe others.

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

Following is the error message:

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

Why does this happen? Is this due to communication latency? If yes, how do I resolve it?

来源:https://stackoverflow.com/questions/46510891/mpi-segmentation-fault-in-master-slave-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!