[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [mpi-21] MPI::BOTTOM



On Nov 27, 2007, at 3:27 PM, Jeff Squyres wrote:

A user recently raised an issue that I just looked into and discovered a problem with the C++ binding for MPI::BOTTOM.

In the spec, MPI::BOTTOM is defined to be of type (const void*). However, all receive buffers are defined to be of type (void*) -- such as for the various flavors of point-to-point receive, the receive buffer for collectives, etc. This means that you'll get a compiler error when trying to use MPI::BOTTOM as a receive buffer:

bottom.cc:81: error: invalid conversion from ‘const void*’ to ‘void*’
bottom.cc:81: error: initializing argument 1 of ‘virtual void MPI::Comm::Bcast(void*, int, const MPI::Datatype&, int) const’


A user can cast away the const-ness of MPI::BOTTOM, but that seems inelegant/wrong.

I don't yet have a solution to this problem; I raise it here so that it gets added to the list of issues to be addressed in MPI-2.1.

Looks like the const is on the wrong side of the declaration. That is, unless my C++ is too rusty it should instead be something like:


namespace MPI {
  ...
  extern void * const BOTTOM;
  ...
}

"const TYPE * FOO" indicates that the data pointed to by FOO is read- only. So "*FOO = BAR;" would be an illegal statement.

"TYPE * const FOO" indicates that the memory holding the value of FOO is read-only. So "FOO = &BAR;" would be an illegal statement.

The latter seems to be what is desired for MPI::BOTTOM: an address that cannot be changed but a the data that it references can.

--
Dave Goodell
Argonne National Laboratory