Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2006-03-03 19:18:52

On Mar 3, 2006, at 6:42 PM, Xiaoning (David) Yang wrote:

> & MPI_COMM_WORLD,ierr)
> Can I use MPI_IN_PLACE in the MPI_REDUCE call? If I can, how?
> Thanks for any help!

MPI_IN_PLACE is an MPI-2 construct, and is defined in the MPI-2
standard. Its use in MPI_REDUCE is defined in section 7.3.3:

It says:

"The ``in place'' option for intracommunicators is specified by
passing the value MPI_IN_PLACE to the argument sendbuf at the root.
In such case, the input data is taken at the root from the receive
buffer, where it will be replaced by the output data."

In the simple pi example program, it doesn't make much sense to use
MPI_IN_PLACE except as an example to see how it is used (i.e., it
won't gain much in terms of efficiency because you're only dealing
with a single MPI_DOUBLE_PRECISION). But you would want to put an
"if" statement around the call to MPI_REDUCE and pass MPI_IN_PLACE as
the first argument, and mypi as the second argument for the root.
For all other processes, use the same MPI_REDUCE that you're using now.

{+} Jeff Squyres
{+} The Open MPI Project