cout slowest processor MPI
问题 I am writing a program using MPI. Each processor executes a for loop: int main(int argc, char** argv) { boost::mpi::environment env(argc, argv); for( int i=0; i<10; ++i ) { std::cout << "Index " << i << std::endl << std::flush; } } Is there a way to make the cout only happen on the last processor to hit index i? Or flag so a line is only executed on the last processor to get to it? 回答1: It might look like trivial, but actually, what you ask here is extremely complex for distributed memory