6.1.9. Commit and Free

PreviousUpNext
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)
C binding
int MPI_Type_commit(MPI_Datatype *datatype)
Fortran 2008 binding
MPI_Type_commit(datatype, ierror)

TYPE(MPI_Datatype), INTENT(INOUT) :: datatype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
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.

The optimizations chosen during MPI_TYPE_COMMIT may no longer be optimal if a session (or the World Model) is initialized or finalized. ( 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.

Image file

MPI_TYPE_FREE(datatype)
INOUT datatypedatatype that is freed (handle)
C binding
int MPI_Type_free(MPI_Datatype *datatype)
Fortran 2008 binding
MPI_Type_free(datatype, ierror)

TYPE(MPI_Datatype), INTENT(INOUT) :: datatype
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
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. 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 than 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.)


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


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

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023