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;