IBM Books

MPI Subroutine Reference

MPI_COMM_SET_ATTR, MPI_Comm_set_attr

Purpose

Attaches the communicator attribute value to the communicator and associates it with the key.

C synopsis

#include <mpi.h>
int MPI_Comm_set_attr (MPI_Comm comm, int comm_keyval, void *attribute_val);

C++ synopsis

#include mpi.h
void MPI::Comm::Set_attr(int comm_keyval, const void* attribute_val) const;

FORTRAN synopsis

include 'mpif.h' or use mpi
MPI_COMM_SET_ATTR(INTEGER COMM, INTEGER COMM_KEYVAL,
                  INTEGER ATTRIBUTE_VAL, INTEGER IERROR)

Parameters

comm
is the communicator to which the attribute will be attached (handle) (INOUT)

comm_keyval
is the key value (integer) (IN)

attribute_val
is the attribute value (IN)

IERROR
is the FORTRAN return code. It is always the last argument.

Description

This subroutine stores the attribute value for retrieval by MPI_COMM_GET_ATTR. Any previous value is deleted with the attribute delete_fn being called and the new value is stored. If there is no key with value keyval, the call is erroneous.

Notes

MPI_COMM_SET_ATTR supersedes MPI_ATTR_PUT.

MPI_COMM_SET_ATTR does not interoperate with MPI_ATTR_PUT. The FORTRAN bindings for MPI-1 caching functions presume that an attribute is an INTEGER. The MPI-2 caching bindings use INTEGER (KIND=MPI_ADDRESS_KIND). In an MPI implementation that uses 64-bit addresses and 32-bit INTEGERS, the two formats would be incompatible.

The implementation of MPI_COMM_SET_ATTR and MPI_COMM_GET_ATTR involves saving a single word of information in the communicator. The languages C and FORTRAN have different approaches to using this capability:

In C: As the programmer, you normally define a struct that holds arbitrary "attribute" information. Before calling MPI_COMM_SET_ATTR, you allocate some storage for the attribute structure and then call MPI_COMM_SET_ATTR to record the address of this structure. You must make sure that the structure remains intact as long as it may be useful. As the programmer, you will also declare a variable of type "pointer to attribute structure" and pass the address of this variable when calling MPI_COMM_GET_ATTR. Both MPI_COMM_SET_ATTR and MPI_COMM_GET_ATTR take a void* parameter, but this does not imply that the same parameter is passed to either one.

In FORTRAN: MPI_COMM_SET_ATTR records an address-size integer and MPI_COMM_GET_ATTR returns the address-size integer. As the programmer, you can choose to encode all attribute information in this integer or maintain some kind of database in which the integer can index. Either of these approaches will port to other MPI implementations.

XL FORTRAN has an additional feature that will allow some of the same functions a C programmer would use. This is the POINTER type, which is described in the IBM XL FORTRAN Compiler for AIX Language Reference. Use of this feature will impact the program's portability.

Errors

Fatal errors:

MPI not initialized

MPI already finalized

Wrong keytype (MPI_ERR_ARG) attribute key is not a communicator key

Related information

MPI_ATTR_PUT
MPI_COMM_DELETE_ATTR
MPI_COMM_GET_ATTR


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]