Commit and free


Up: Derived datatypes Next: Use of general datatypes in communication Previous: Lower-bound and upper-bound markers

A datatype object has to be committed before it can be used in a communication. A committed datatype can still be used as a argument in datatype constructors. There is no need to commit basic datatypes. They are ``pre-committed.''

MPI_TYPE_COMMIT(datatype)
[ INOUT datatype] datatype that is committed (handle)

int MPI_Type_commit(MPI_Datatype *datatype)

MPI_TYPE_COMMIT(DATATYPE, IERROR)
INTEGER DATATYPE, IERROR

The commit operation commits the datatype, that is, the formal description of a communication buffer, not the content of that buffer. Thus, after a datatype has been committed, it can be repeatedly reused to communicate the changing content of a buffer or, indeed, the content of different buffers, with different starting addresses.


[] Advice to implementors.

The system may ``compile'' at commit time an internal representation for the datatype that facilitates communication, e.g. change from a compacted representation to a flat representation of the datatype, and select the most convenient transfer mechanism. ( End of advice to implementors.)
MPI_TYPE_FREE(datatype)
[ INOUT datatype] datatype that is freed (handle)

int MPI_Type_free(MPI_Datatype *datatype)

MPI_TYPE_FREE(DATATYPE, IERROR)
INTEGER DATATYPE, IERROR

Marks the datatype object associated with datatype for deallocation and sets datatype to MPI_DATATYPE_NULL. Any communication that is currently using this datatype will complete normally. Derived datatypes that were defined from the freed datatype are not affected.


  
 
The following code fragment gives examples of using 
 MPI_TYPE_COMMIT. 
 
INTEGER type1, type2 
CALL MPI_TYPE_CONTIGUOUS(5, MPI_REAL, type1, ierr) 
              ! new type object created 
CALL MPI_TYPE_COMMIT(type1, ierr) 
              ! now type1 can be used for communication 
type2 = type1 
              ! type2 can be used for communication 
              ! (it is a handle to same object as type1) 
CALL MPI_TYPE_VECTOR(3, 5, 4, MPI_REAL, type1, ierr) 
              ! new uncommitted type object created 
CALL MPI_TYPE_COMMIT(type1, ierr) 
              ! now type1 can be used anew for communication 
Freeing a datatype does not affect any other datatype that was built from the freed datatype. The system behaves as if input datatype arguments to derived datatype constructors are passed by value.


[] Advice to implementors.

The implementation may keep a reference count of active communications that use the datatype, in order to decide when to free it. Also, one may implement constructors of derived datatypes so that they keep pointers to their datatype arguments, rather then copying them. In this case, one needs to keep track of active datatype definition references in order to know when a datatype object can be freed. ( End of advice to implementors.)



Up: Derived datatypes Next: Use of general datatypes in communication Previous: Lower-bound and upper-bound markers


Return to MPI Standard Index
Return to MPI home page