MPI_TYPE 相關方法

MPI_Type_extent(MPI_Datatype datatype,MPI_Aint extent)
return the extent of a datatype.
MPI_Type_size(MPI_Datatype datatype,int *size)
return the total size,in bytes,of the entries in the type signature associated with datatype.
eg:type={(double,0),(char 8)}(a double at displacement zero,followed by a char at displacement eight)
a call to MPI_Type_extent(type,i) will return i=16,a call to MPI_Type_size(type,i) will return i=9.

MPI_Type_contiguous(int count,MPI_Datatype oldType,MPI_Datatype *newType)
return a newType consisting of the replication of a datatype into contiguous location.
eg:type={(double,0),(char 8)},let count=3,call MPI_Type_contiguous(3,type,newtype),so the newtype={(double,0),(char 8),(double,16),(char 24),(double,32),(char 40)}

MPI_Type_vector(int count,int blocklen,int stride,MPI_Datatype oldtype,MPI_datatype *newtype)
it is a constructor that allows replication of a datatype into locations that consist of equally spaced(隔開的) blocks.
eg:type={(double,0),(char 8)}
a call to MPI_Type_vector(2,3,4,type,newtype) will create the datatype with 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)},there are 2 bolcks,the size of every block is 3(3 copys of oldtype),and the extent of every block is 4(only 3 is occupied).

MPI_Type_hvector(int count,int blocklen,MPI_Aint stride,MPI_Datatype oldtype,MPI_datatype *newtype)
it is identical to MPI_Type_vevtor,excep that stride is given in bytes,rather than in elements.
eg:type={(double,0),(char 8)}
a call to MPI_Type_hvector(2,3,4,type,newtype) will create the datatype with newtype={(double,0),(char 8),(double,16),(char 24),(double,32),(char 40), (double,4),(char 12),(double,20),(char 28),(double,36),(char 44)},there are 2 bolcks,the size of every block is 3(3 copys of oldtype),and the distance of two block is 4.

MPI_Type_indexed(int count,int *array_of_blocklengths,int *array_of_displacement,MPI_Datatype oldtype,MPI_Datatype *newtype)
it allows replication of an old datatype into a sequence of blocks,where each block can contain a different number of copies of oldtype and have a different displacement.
eg:type={(double,0),(char 8)},let B={3,1},D={4,0}
a call to MPI_Type_indexed(2,B,D,type,newtype) returns a datatype with type map {(double,64),(char 72),(double,80),(char 88),(double,96),(char 104),(double,0),(char 8)},the length of first block is 3 oldtypes,and the displacement is 4*16,the second block’s length is 1,and the displacment is 0*16.

MPI_Type_hindexed(int count,int *array_of_blocklengths,MPI_Aint *array_of_displacement,MPI_Datatype oldtype,MPI_Datatype *newtype)
it is identical to MPI_Type_vevtor,excep that stride is given in bytes,rather than in elements.

MPI_Type_struct(int count,int *array_of_blocklengths,MPI_Aint *array_of_displacements,MPI_Datatype *array_of_types,MPI_Datatype *newtype)
it further generalizes MPI_Type_hindexed in that it allows each block to consist of replications of different datatype.
eg:type={(double 0),(char 8)},let B={2,1,3},D={0,16,26},T={MPI_FLOAT,type,MPI_CHAR},then a call to MPI_Type_struct(3,B,D,T,newtype) return a datatype newtype={(float 0),(flat 4),(double 16),(char 24),(char 26),(char 27),(char 28)}.The first block’s length 2(2 copys of MPI_FLOAT),displacement is 0,so it is (float 0),(flat 4).The second block’s length 1(1 copys of type),displacement is 16,so it is (double 16),(char 24).The third block’s length 3(3 copys of MPI_CHAR),displacement is 26,so it is (char 26),(char 27),(char 28).

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章