通过阅读文档,MPI_Bcast 也是一个阻塞调用(因此 boost::mpi::broadcast)也是如此。测量根节点广播所需的时间是否可以很好地衡量数据从根节点到所有其他节点所需的时间?
IE
int64_t t1 = Utility::picosecondTime(); //exactly what it sounds like; utility that measures current time in picoseconds
boost::mpi::broadcast(communicator, variable, 0);
std::cout << "Broadcast took " << Utility::picosecondTime()-t1 << std::endl;
或者对于直接的 OpenMPI:
MPI_Comm comm;
int array[100];
...
int64_t t1 = Utility::picosecondTime();
MPI_Bcast( array, 100, MPI_INT, 0, comm);
std::cout << "Broadcast took " << Utility::picosecondTime()-t1 << std::endl;