向量数据类型
MPI_TYPE_VECTOR(count,blocklength,stride,oldtype,newtype)
IN count 块的数量(非负整数)
IN blocklength 每个块中所含元素个数(非负整数)
IN stride 各块第一个元素之间相隔的元素个数(整数)
IN oldtype 旧数据类型(句柄)
OUT newtypr 新数据类型(句柄)
int MPI_Type_vector(int count,int blocklength,int stride,
MPI_Datatype oldtype,MPI_Datatype *newtype)
MPI_TYPE_VECTOR(COUNT,BLOCKLENGTH,STRIDE,OLDTYPE,
NEWTYPE,IERROR)
INTEGER COUNT,BLOCKLENGTH,STRIDE,OLDTYPE,NEWTYPE,IERROR

MPI_TYPE_VECTOR是一个更通用的生成器,允许复制一个数据类型到含有相等大小块的空间。每个块通过连接相同数量的旧数据类型的拷贝来获得。块与块之间的空间是旧数据类型的extent的倍数。

假设旧数据类型oldtype的类型图为{(double,0),(char,8)},extent=16.则MPI_TYPE_VECTOR(2,3,4,oldtype,newtype)调用生成的数据类型的类型图为:
{(double,0),(char,8), (double,16),(char,24), (double,32),(char,40),
(double,64),(char,72), (double,80),(char,88),(double,96),(char,104)}.
即两个块,每个旧类型有三个拷贝,相邻块之间的步长stride为4个元素。

图13-3 用MPI_TYPE_VECTOR产生的新数据类型



MPI_TYPE_CONTIGUOUS( count, oldtype, newtype )调用等价于调用MPI_TYPE_VECTOR( count, 1, 1, oldtype, newtype ),或调用MPI_TYPE_VECTOR(1, count, n, oldtype, newtype), n为任意整数。

索引数据类型
MPI_TYPE_INDEXED(count,array_of_blocklengths,array_of_displacemets,oldtype,newtype)
IN count 块的数量(整型)
IN array_of_blocklengths 每个块中所含元素个数(非负整数数组)
IN array_of_displacements 各块偏移值 (整数数组)
IN oldtype 旧数据类型(句柄)
OUT newtypr 新数据类型(句柄)
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

MPI_TYPE_INDEXED允许复制一个旧数据类型到一个块序列中,每个块可以包含不同的拷贝数目和具有不同的偏移.所有的块偏移都是旧数据类型extent的倍数.

设oldtype的类型映像为
{(double,0),(char,8)},extent=16.
令B=(3,1),D=(4,0),则MPI_TYPE_INDEXED( 2, B, D, oldtype, newtype ) 调用生成的数据类型映像是:
{(double,64),(char,72), (double,80),(char,88),(double,96),(char,104), (double,0),(char,8)}.

图13-4 用MPI_TYPE_INDEXED产生的新数据类型