8.8.1 Communicators

The new functions that are replacements for the MPI-/ functions for caching on communicators are:



MPI_COMM_CREATE_KEYVAL(comm_copy_attr_fn, comm_delete_attr_fn, comm_keyval, extra_state)

IN
comm_copy_attr_fn copy callback function for comm_keyval (function)
IN
comm_delete_attr_fn delete callback function for comm_keyval (function)
OUT
comm_keyval key value for future access (integer)
IN
extra_state extra state for callback functions

int MPI_Comm_create_keyval(MPI_Comm_copy_attr_function *comm_copy_attr_fn, MPI_Comm_delete_attr_function *comm_delete_attr_fn, int *comm_keyval, void *extra_state)



MPI_COMM_CREATE_KEYVAL(COMM_COPY_ATTR_FN, COMM_DELETE_ATTR_FN, COMM_KEYVAL, EXTRA_STATE, IERROR)EXTERNAL COMM_COPY_ATTR_FN, COMM_DELETE_ATTR_FN
INTEGER COMM_KEYVAL, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE



int MPI::Comm::Create_keyval(MPI::Comm::Copy_attr_function* comm_copy_attr_fn, MPI::Comm::Delete_attr_function* comm_delete_attr_fn, void* extra_state)



static int

This function replaces MPI_KEYVAL_CREATE, whose use is deprecated. The C binding is identical. The Fortran binding differs in that extra_state is an address-sized integer. Also, the copy and delete callback functions have Fortran bindings that are consistent with address-sized attributes.

The argument comm_copy_attr_fn may be specified as MPI_COMM_NULL_COPY_FN or MPI_COMM_DUP_FN from either C, C++, or Fortran. MPI_COMM_NULL_COPY_FN is a function that does nothing other than returning flag = 0 and MPI_SUCCESS. MPI_COMM_DUP_FN is a simple-minded copy function that sets flag = 1, returns the value of attribute_val_in in attribute_val_out, and returns MPI_SUCCESS. These replace the MPI-/ predefined callbacks MPI_NULL_COPY_FN and MPI_DUP_FN, whose use is deprecated.

The argument comm_delete_attr_fn may be specified as MPI_COMM_NULL_DELETE_FN from either C, C++, or Fortran. MPI_COMM_NULL_DELETE_FN is a function that does nothing, other than returning MPI_SUCCESS. MPI_COMM_NULL_DELETE_FN replaces MPI_NULL_DELETE_FN, whose use is deprecated.

The C callback functions are:

typedef int MPI_Comm_copy_attr_function(MPI_Comm oldcomm, int comm_keyval, void *extra_state, void *attribute_val_in, void *attribute_val_out, int *flag);



and

typedef int MPI_Comm_delete_attr_function(MPI_Comm comm, int comm_keyval, void *attribute_val, void *extra_state);



which are the same as the MPI-1.1/ calls but with a new name. The old names are deprecated.

The Fortran callback functions are:

SUBROUTINE COMM_COPY_ATTR_FN(OLDCOMM, COMM_KEYVAL, EXTRA_STATE, ATTRIBUTE_VAL_IN, ATTRIBUTE_VAL_OUT, FLAG, IERROR)INTEGER OLDCOMM, COMM_KEYVAL, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE, ATTRIBUTE_VAL_IN,
ATTRIBUTE_VAL_OUT
LOGICAL FLAG



and

SUBROUTINE COMM_DELETE_ATTR_FN(COMM, COMM_KEYVAL, ATTRIBUTE_VAL, EXTRA_STATE, IERROR)INTEGER COMM, COMM_KEYVAL, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL, EXTRA_STATE



The C++ callbacks are:

typedef int MPI::Comm::Copy_attr_function(const MPI::Comm& oldcomm, int comm_keyval, void* extra_state, void* attribute_val_in, void* attribute_val_out, bool& flag);



and

typedef int MPI::Comm::Delete_attr_function(MPI::Comm& comm, int comm_keyval, void* attribute_val, void* extra_state);





MPI_COMM_FREE_KEYVAL(comm_keyval)

INOUT
comm_keyval key value (integer)

int MPI_Comm_free_keyval(int *comm_keyval)



MPI_COMM_FREE_KEYVAL(COMM_KEYVAL, IERROR)INTEGER COMM_KEYVAL, IERROR



int MPI::Comm::Free_keyval(int& comm_keyval)



static void

This call is identical to the MPI-/ call MPI_KEYVAL_FREE but is needed to match the new communicator-specific creation function. The use of MPI_KEYVAL_FREE is deprecated.



MPI_COMM_SET_ATTR(comm, comm_keyval, attribute_val)

INOUT
comm communicator from which attribute will be attached (handle)
IN
comm_keyval key value (integer)
IN
attribute_val attribute value

int MPI_Comm_set_attr(MPI_Comm comm, int comm_keyval, void *attribute_val)



MPI_COMM_SET_ATTR(COMM, COMM_KEYVAL, ATTRIBUTE_VAL, IERROR)INTEGER COMM, COMM_KEYVAL, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL



int MPI::Comm::Set_attr(int comm_keyval, const void* attribute_val) const



void

This function replaces MPI_ATTR_PUT, whose use is deprecated. The C binding is identical. The Fortran binding differs in that attribute_val is an address-sized integer.



MPI_COMM_GET_ATTR(comm, comm_keyval, attribute_val, flag)

IN
comm communicator to which the attribute is attached (handle)
IN
comm_keyval key value (integer)
OUT
attribute_val attribute value, unless flag = false
OUT
flag false if no attribute is associated with the key (logical)

int MPI_Comm_get_attr(MPI_Comm comm, int comm_keyval, void *attribute_val, int *flag)



MPI_COMM_GET_ATTR(COMM, COMM_KEYVAL, ATTRIBUTE_VAL, FLAG, IERROR)INTEGER COMM, COMM_KEYVAL, IERROR
INTEGER(KIND=MPI_ADDRESS_KIND) ATTRIBUTE_VAL
LOGICAL FLAG



int MPI::Comm::Get_attr(int comm_keyval, void* attribute_val) const



bool

This function replaces MPI_ATTR_GET, whose use is deprecated. The C binding is identical. The Fortran binding differs in that attribute_val is an address-sized integer.



MPI_COMM_DELETE_ATTR(comm, comm_keyval)

INOUT
comm communicator from which the attribute is deleted (handle)
IN
comm_keyval key value (integer)

int MPI_Comm_delete_attr(MPI_Comm comm, int comm_keyval)



MPI_COMM_DELETE_ATTR(COMM, COMM_KEYVAL, IERROR)INTEGER COMM, COMM_KEYVAL, IERROR



int MPI::Comm::Delete_attr(int comm_keyval)



void

This function is the same as MPI_ATTR_DELETE but is needed to match the new communicator specific functions. The use of MPI_ATTR_DELETE is deprecated.

MPI-Standard for MARMOT