const problems with native handle
VictorEijkhout opened this issue · comments
const mpl::communicator &comm =
mpl::environment::comm_world();
MPI_Comm
world_extract = comm.native_handle(),
gives error: 'this' argument to member function 'native_handle' has type 'const mpl::communicator', but function is not marked const
but without const
mpl::communicator &comm =
mpl::environment::comm_world();
gives error: binding reference of type 'mpl::communicator' to value of type 'const mpl::communicator' drops 'const' qualifier
You could fix this by making native_handle
a const
function, but I gues the point to having the native handle is to do MPI_Comm_set_info
and such on it.
@VictorEijkhout: I was expecting this. You can replace mpl::environment::comm_world()
just by MPI_COMM_WORLD
. Thus, this is not an issue.
Nevertheless, I will need to make the native_handle
method const
(not its return value). The reason is, that communicators should be passed as constant references to functions. (MPL communicators have a value semantics. Copying a communicator involves MPI_Comm_dup
, which is usually undesirable.) Thus, if the underling MPI handle of the function argument is needed then we run into the same problem as above with mpl::environment::comm_world()
.