0

I'm trying to create a datatype for 2D sub-matrix and process it using MPI. What I have found so far is this question. Answer to it completely covers my problem. The only thing I can't understand is how the extent of the sub-array datatype is computed. Any explanation would be really helpful.

Here is the code and the statement copied from the answer to that question:

MPI_Datatype newtype;
int sizes[2]    = {6,6};  /* size of global array */
int subsizes[2] = {3,3};  /* size of sub-region */
int starts[2]   = {0,0};  /* let's say we're looking at region "0",
                             which begins at index [0,0] */

MPI_Type_create_subarray(2, sizes, subsizes, starts, MPI_ORDER_C, MPI_INT, &newtype);
MPI_Type_commit(&newtype);

We couldn't just use MPI_Scatter() (or even scatterv) with these types yet, because these types have an extent of 16 integers;

Community
  • 1
  • 1

1 Answers1

0

In fact, I think these have an extent of 36 integers not 16? In any case, you are correct that this extent means that it is not easy to subarray types in Scatter or Scatterv operations.

You need to use MPI_Type_create_resized to fix the extent to something more useful, e.g. a single integer.

I answered a similar question in C - MPI - Send/Receive Subarrays to Array - a more complete explanation was posted by Jonathan Dursi in sending blocks of 2D array in C using MPI

Community
  • 1
  • 1
David Henty
  • 1,694
  • 9
  • 11