By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,946 Members | 1,298 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,946 IT Pros & Developers. It's quick & easy.

Output in C++ with MPI.

P: n/a
It is well known that in MPI it usually suffices if only one process
performs output. The output is most often directed to the console, i.e.
to cout. However, it is tedious to write code to check the rank of the
process in order to decide whether this is the process that has been
designated to perform output:

if( MPI_Comm_rank( comm ) == 0 )
{
std::cout << something;
}

Has anyone devised a better alternative besides this one:

template< typename t >
void MPIPrint( t const& smth_to_print )
{
if( MPI_Comm_rank( comm ) == 0 )
{
std::cout << smth_to_print;
}
}

MPIPrint( something );

In fact, I'm interested if there is some way to introduce a new
manipulator to be used in cases such as:

cout << set_MPI_comm( comm ) << something; // Checks rank to decide
whether to print.

Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
What about redirecting stdout to /dev/null on all processes
other than rank 0?

Nov 29 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.