MPI_Gather: Segmentation fault in Master Slave Program

左心房为你撑大大i 提交于 2019-12-11 15:19:23

问题


Following is a simple program where all Slaves process send their rank (as the token) to the Master process.

The program when executed runs correctly most of the times but raises Segmentation Fault the others.

int token = rank;
vector<int> recvData(world_size);

MPI_Gather(&token, 1, MPI_INT, &recvData[0], 1, MPI_INT, 0, MPI_COMM_WORLD);

if(rank == 0)
{
    // Root process
    for (int irank = 1; irank < world_size; irank++)
    {
        cout << "Token received from rank " << irank << " = " << recvData[irank] << endl;
    }
}

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

Is there any way to avoid such situations?

Edit 1: Following are the outputs of mpirun when ran in verbose mode (both cases):

i) Success Case

ii) Segmentation Fault Case

P.S.: I asked a similar question to this today, and a suggestion was given to use MPI_Gather() but the problem still persists.

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

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