MPI offers a suitable collection of basic datatypes to use in messages, but the predefined types operate under two rather restrictive assumptions:

  • the data to be communicated must be in contiguous memory locations;
  • they must consist of just one basic type and no other.

So, what if your application needs to communicate data of mixed type? Or what if your data are stored in non-contiguous locations? You could always invent a custom solution involving multiple MPI calls, copying data into a buffer, packing, unpacking, etc. But such a solution is likely to be slow, clumsy, and wasteful of memory.

A better solution is to use MPI's built-in mechanisms to create derived datatypes from existing datatypes for your own special needs. These types are called "derived" because their properties are derived from, or built upon, the more fundamental types.

Derived datatypes offer several advantages:

  • derived datatypes can be built up recursively;
  • they can be created conditionally, at runtime;
  • the associated packing and unpacking are done for you automatically.
 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement