我有一个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