LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2005-10-17 09:41:50


On Oct 12, 2005, at 9:25 AM, L WK wrote:

> A similar question have been asked in this forum months ago. I get
> some information from that reply but still have a question about that.
> I am wondering if there is any way to reduce a data of a special
> datatype(like checkboard-shape, with data located on the black grid)

Sorry for the delay in replying -- we were all at a working group
meeting last week, and I fell behind on e-mail.

> It is easy to create such datatype(says CSData), however, the
> following calling is invalid in MPI as mentioned before
>
> MPI_Reduce( &src, &dest, 1, CSData, myOp, 0, MPI_COMM_WORLD);
>
> MPI_Reduce knows nothing about the CSData and only ONE element will be
> reduced actually.

This should actually work just fine -- you have told MPI that you want
to reduce 1 instance of data represented by the CSData datatype. Are
you intending something else?

> I am going to reduce the data limited by CSData. For that, I will
> first copy all data needed into a temporary buffer and then reduce the
> buffer, at last copy the buffer to the destionation accordingly to the
> checkboard structure. This method is too raw and the inefficient. I am
> looking for a better way!

MPI_Reduce does not require contiguous buffers.

You can supply any buffer, count, and datatype to MPI_Reduce, assuming
that the reduction function associated with the MPI_Op that you use
understands the datatype and structure of the buffers that it will
receive. Pre-defined MPI operations only understand certain datatypes
(e.g., if you try to MPI_SUM on a user-defined datatype, it won't
work). But if you're defining your own reduction operation, assumedly
you can write your own callback function that understands the data
structure (e.g., checkerboard) without all the extra copying.
Specifically, you should be able to reduce directly to your target
buffers without extra copying.

Hope that helps.

-- 
{+} Jeff Squyres
{+} The Open MPI Project
{+} http://www.open-mpi.org/