Indexed

The function MPI_TYPE_INDEXED allows replication of an old datatype into a sequence of blocks (each block is a concatenation of the old datatype), where each block can contain a different number of copies and have a different displacement. All block displacements are multiples of the old type extent.



MPI_TYPE_INDEXED( count, array_of_blocklengths, array_of_displacements, oldtype, newtype)

IN
count number of blocks - also number of entries in
array_of_displacements and array_of_blocklengths (nonnegative integer)
IN
array_of_blocklengths number of elements per block (array of nonnegative integers)
IN
array_of_displacements displacement for each block, in multiples of oldtype extent (array of integer)
IN
oldtype old datatype (handle)
OUT
newtype new datatype (handle)

int MPI_Type_indexed(int count, int *array_of_blocklengths, int *array_of_displacements, MPI_Datatype oldtype, MPI_Datatype *newtype)



MPI_TYPE_INDEXED(COUNT, ARRAY_OF_BLOCKLENGTHS, ARRAY_OF_DISPLACEMENTS, OLDTYPE, NEWTYPE, IERROR)
INTEGER COUNT, ARRAY_OF_BLOCKLENGTHS(*), ARRAY_OF_DISPLACEMENTS(*), OLDTYPE, NEWTYPE, IERROR



Example 3..23  

Let oldtype have type map \(
\{ ({\sf double}, 0), ({\sf char}, 8) \} ,
\) with extent 16. Let B = (3, 1) and let D = (4, 0). A call to MPI_TYPE_INDEXED(2, B, D, oldtype, newtype) returns a datatype with type map,

\begin{displaymath}
\{
({\sf double}, 64), ({\sf char}, 72), ({\sf double}, 80), ({\sf char},
88), ({\sf double}, 96), ({\sf char}, 104),
\end{displaymath}


\begin{displaymath}
({\sf double}, 0), ({\sf char}, 8)
\} .
\end{displaymath}

That is, three copies of the old type starting at displacement 64, and one copy starting at displacement 0.




In general, assume that oldtype has type map,

\begin{displaymath}
\{ (type_0,disp_0), ..., (type_{n-1}, disp_{n-1}) \} ,
\end{displaymath}

with extent ex. Let B be the array_of_blocklength argument and D be the
array_of_displacements argument. The newly created datatype has $n \cdot \sum_{i=0}^{{\sf count}-1}
{\sf B[i]}$ entries:

\begin{displaymath}
\{
(type_0, disp_0 + {\sf D[0]} \cdot ex ) , ... ,
(type_{n-1} , disp_{n-1} + {\sf D[0]} \cdot ex ) , ... ,
\end{displaymath}


\begin{displaymath}
(type_0 , disp_0 + ({\sf D[0]} + {\sf B[0]} -1) \cdot ex) ,....
...} , disp_{n-1} + ({\sf D[0]} +{\sf B[0]} -1) \cdot ex ) ,
...,
\end{displaymath}


\begin{displaymath}
(type_0, disp_0 + {\sf D[count-1]} \cdot ex ) , ... ,
(type_{n-1} , disp_{n-1} + {\sf D[count-1]} \cdot ex ) , ... ,
\end{displaymath}


\begin{displaymath}
(type_0 , disp_0 + ({\sf D[count-1]} + {\sf B[count-1]} -1) \cdot ex)
,...,
\end{displaymath}


\begin{displaymath}
(type_{n-1} , disp_{n-1} + ({\sf D[count-1]} +{\sf B[count-1]} -1)
\cdot ex )
\} .
\end{displaymath}




A call to MPI_TYPE_VECTOR(count, blocklength, stride, oldtype, newtype) is equivalent to a call to MPI_TYPE_INDEXED(count, B, D, oldtype, newtype) where

\begin{displaymath}
{\sf D[j]} = j \cdot {\sf stride},\ j=0 ,..., {\sf count} -1 ,
\end{displaymath}

and

\begin{displaymath}
{\sf B[j]} = {\sf blocklength},\ j=0 ,..., {\sf count} -1 .
\end{displaymath}

MPI-Standard for MARMOT