References:

Up to this point, all examples have used already defined MPI types, but you can create your own to pass and receive messages.

Committing a type (MPI_Type_commit):

All types created with the routines shown below need to call this function before using them in communication, in order to submit the created type.

Function prototype:

int MPI_Type_commit(
	MPI_Datatype *type //Created type address
);

Deleting a type (MPI_Type_free):

It deallocates the resources assigned to an MPI_Datatype and sets it to MPI_DATATYPE_NULL, ****which is a const. Communications that are currently using it will complete normally and MPI datatypes built on the freed one are not affected.

Function prototype:

int MPI_Type_free(
	MPI_Datatype *type //Created type address
);

Note: The codes shown below are just examples; they do not use MPI_Type_free, but it is important to always free the type's memory after finishing their use.

Struct (MPI_Type_create_struct):