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.