[mpich-discuss] How to use MPI::COMM::Gather & MPI::Op::Init(MPI_Op_create))

Nicolas Rosner nrosner at gmail.com
Sat Apr 9 11:21:56 CDT 2011


Hi Kong Tao,

> I don't know the difference between the second parameter
> (sendcount) and the fifth parameter (recvcount).

This is well documented on manpages and examples (try doing a Web
search for "mpi_gather example" or so). But here are some things to
keep in mind:

Parameters like recvbuf and recvcount will only be meaningful to the
root process (the rank that will receive data gathered from all
participants, including itself). The rest of the callers will simply
ignore those values.

The recvcount parameter describes how many items to receive *per
sender*, just like the sendcount describes how many each should send.
So you will never need to explicitly write how many *total* items you
want to receive at the root.

In other words, if 5 ranks are going to send 80 ints each, you should
never need to write the number 400 explicitly anywhere. This means
that in most cases, e.g. assuming recvtype and sendtype are the same,
your recvcount will indeed be the same number as your sendcount.


> Can they be different?

Yes. Check out the 3rd example, where a derived datatype is used, here:

   http://linux.die.net/man/3/mpi_gather


I'm not too familiar with the C++ bindings for user-defined reduce
ops, but I'm wondering -- does the sample you provided even compile at
all? At the very least, you seem to have misspelled a variable name on
both reduce calls ("resut1" instead of "result1", etc).


Hope this helps!

N.


More information about the mpich-discuss mailing list