---
title: 数据类型
description: "- 创建连续的数据类型。"
url: https://www.hikunpeng.com/document/detail/zh/hpchistory/hpckit/develop2400/userg_hyperio_0015.html
sourcePath: /source/zh/hpchistory/hpckit/develop2400/userg_hyperio_0015.html
indexId: 8e07aa0974e06401f711ec860e6f4dc6b1ebaff6c75a51b86f26d735ee7baae964
---
# 数据类型

#### 函数定义

- 创建连续的数据类型。
  MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype)

  PMPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype)

- 创建矢量数据类型。
  MPI_Type_vector(int count, int blocklength, int stride, MPI_Datatype oldtype, MPI_Datatype *newtype)

  PMPI_Type_vector(int count, int blocklength, int stride, MPI_Datatype oldtype, MPI_Datatype *newtype)

- 创建偏移量位的矢量数据类型。
  MPI_Type_create_hvector(int count, int blocklength, MPI_Aint stride, MPI_Datatype oldtype, MPI_Datatype *newtype)

  PMPI_Type_create_hvector(int count, int blocklength, MPI_Aint stride, MPI_Datatype oldtype, MPI_Datatype *newtype)

- 创建描述n维数组的子数组的数据类型。
  MPI_Type_create_subarray(int ndims, const int sizeArray[], const int subSizeArray[], const int subStartArray[], int order, MPI_Datatype oldtype, MPI_Datatype *newtype)

  PMPI_Type_create_subarray(int ndims, const int sizeArray[], const int subSizeArray[], const int subStartArray[], int order, MPI_Datatype oldtype, MPI_Datatype *newtype)

- 提交数据类型。
  MPI_Type_commit(MPI_Datatype *type)

  PMPI_Type_commit(MPI_Datatype *type)

- 复制具有关联键值的数据类型。
  MPI_Type_dup(MPI_Datatype oldtype, MPI_Datatype *newtype)

  PMPI_Type_dup(MPI_Datatype oldtype, MPI_Datatype *newtype)

- 释放自定义数据类型。
  MPI_Type_free(MPI_Datatype *type)

  PMPI_Type_free(MPI_Datatype *type)


#### 参数

| 参数名 | 描述 | 取值范围 | 输入/输出 |
| --- | --- | --- | --- |
| count | 块数 | 正整数 | 输入 |
| blocklength | 每个块中的元素个数 | 正整数 | 输入 |
| stride | 每个块开始之间的元素数 | 正整数 | 输入 |
| ndims | 数组维度数 | 正整数[1, 10] | 输入 |
| order | 数组存储顺序标志 | 正整数（MPI\_ODER\_C、MPI\_ODER\_FORTRAN） | 输入 |
| sizeArray[] | 完整数组的每个维度中oldtype类型的元素数 | 正整数数组 | 输入 |
| subSizeArray[] | 子数组的每个维度中oldtype类型的元素数 | 正整数数组 | 输入 |
| subStartArray[] | 每个维度中子数组的起始坐标 | 非负数数组 | 输入 |
| oldtype | 旧数据类型（句柄） | 有效句柄 | 输入 |
| \*newtype | 目标地址，存放新的类型（句柄） | 非空 | 输出 |
| \*type | 释放的自定义数据类型（句柄） | 非空 | 输入 |


#### 返回值

- 成功：返回MPI_SUCCESS。
- 失败：返回错误码。


#### 错误码

| 错误码 | 描述 |
| --- | --- |
| MPI\_ERR\_COUNT | 无效count参数 |
| MPI\_ERR\_TYPE23 | 无效数据类型参数 |
| MPI\_ERR\_ARG | 其他类型的无效参数 |
| MPI\_ERR\_OTHER | 其他错误 |


#### 注意

- oldtype目前仅支持MPI基本数据类型。
- count *（oldtype字节数）必须<=INT_MAX。
- blocklength * count *（oldtype字节数）必须<=INT_MAX。
