问题
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 Fault
the 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