Open MPI logo

Open MPI User's Mailing List Archives

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

Subject: [OMPI users] MPI_IN_PLACE variant of MPI_Reduce
From: Martin Siegert (siegert_at_[hidden])
Date: 2009-11-09 23:47:11


Hi,

I am confused about the syntax of the "in place" variant of
MPI_Reduce, in particular about the significance of the recvbuf
for the non-root processes. I.e., is the following legal?

buf = (double *)malloc(l*sizeof(double);
random(buf, l); /* fill buf with something */
if (myid == 0) {
   MPI_Reduce(MPI_IN_PLACE, buf, l, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
} else {
   MPI_Reduce(buf, NULL, l, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
}

This appears to violate the standard:
http://www.mpi-forum.org/docs/mpi22-report/node103.htm#Node103
"The routine is called by all group members using the same arguments for
 count, datatype, op, root and comm. Thus, all processes provide input
 buffers and output buffers of the same length, with elements of the
 same type."

However, this "same length" requirement is already violated at the root
process where I can specify MPI_IN_PLACE. Unfortunately, the standard
says nothing about the other processes in this case. Do I need a valid
receive buffer there?

Cheers,
Martin

-- 
Martin Siegert
Head, Research Computing
WestGrid Site Lead
IT Services                                phone: 778 782-4691
Simon Fraser University                    fax:   778 782-4242
Burnaby, British Columbia                  email: siegert_at_[hidden]
Canada  V5A 1S6