Derived Data Types

5. Key Points

  • Derived datatypes provide a portable and elegant way of communicating non-contiguous or mixed types in a message.

  • Derived datatypes should provide an efficient method of sending data since the data can be moved from its location in one process's memory to a location in a different process's memory without any intermediate buffering. (Note, however, that you may wish to compare the speed using MPI_BYTE to that using your derived datatype.)

  • Derived datatypes are datatypes that are built from the basic MPI datatypes.

  • Derived datatypes provide a template of the data that is to be sent. All the data in the datatype is identified by its offset from the base address. The base address is the address which is passed to the MPI routine using the derived datatype. This allows the same MPI datatype to be used for any number of variables of the same form.

  • MPI provides a number of different routines for creating derived datatypes, each aimed at certain types of data, i.e., contiguous data, non-contiguous data, and non-contiguous mixed data.

  • Every derived datatype must be committed before it can be used.

  • The MPI routine MPI_TYPE_EXTENT is useful for calculating displacements as it takes into account any alignment issues.