以下是一个简单的程序,其中所有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);
}
以下是错误消息:
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
为什么会这样?这是由于通信延迟吗?如果是,我该如何解决?