77. Commit and Free


Up: Derived Datatypes Next: Duplicating a Datatype Previous: True Extent of Datatypes

A datatype object has to be committed before it can be used in a communication. As an argument in datatype constructors, uncommitted and also committed datatypes can be used. There is no need to commit basic datatypes. They are ``pre-committed.''

MPI_TYPE_COMMIT(datatype)
INOUT datatypedatatype that is committed (handle)

int MPI_Type_commit(MPI_Datatype *datatype)

MPI_TYPE_COMMIT(DATATYPE, IERROR)
INTEGER DATATYPE, IERROR
{ void MPI::Datatype::Commit() (binding deprecated, see Section Deprecated since MPI-2.2 ) }
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_COMMIT will accept a committed datatype; in this case, it is equivalent to a no-op.


Example 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 

MPI_TYPE_FREE(datatype)
INOUT datatypedatatype that is freed (handle)

int MPI_Type_free(MPI_Datatype *datatype)

MPI_TYPE_FREE(DATATYPE, IERROR)
INTEGER DATATYPE, IERROR
{ void MPI::Datatype::Free() (binding deprecated, see Section Deprecated since MPI-2.2 ) }
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. 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: Duplicating a Datatype Previous: True Extent of Datatypes


Return to MPI-2.2 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-2.2 of September 4, 2009
HTML Generated on September 10, 2009