我有一个int
我打算从根到广播( rank==(FIELD=0)
int winner
if (rank == FIELD) {
winner = something;
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Bcast(&winner, 1, MPI_INT, FIELD, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
if (rank != FIELD) {
cout << rank << " informed that winner is " << winner << endl;
}
但现在看来,我得到
[JM:6892] *** An error occurred in MPI_Bcast
[JM:6892] *** on communicator MPI_COMM_WORLD
[JM:6892] *** MPI_ERR_TRUNCATE: message truncated
[JM:6892] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort
发现我可以增加缓冲区大小Bcast
MPI_Bcast(&winner, NUMPROCS, MPI_INT, FIELD, MPI_COMM_WORLD);
其中NUMPROCS
是正在运行的进程数。 (其实好像我只需要它为2)。 然后,它运行,但给人意想不到的输出...
1 informed that winner is 103
2 informed that winner is 103
3 informed that winner is 103
5 informed that winner is 103
4 informed that winner is 103
当我cout
了winner
,应该是-1