当前位置: 首页 > news >正文

西塞山区建设局网站郑州建网站msgg

西塞山区建设局网站,郑州建网站msgg,免费高清图片素材网站有哪些,网站如何做好seo内置类型 MPI_CHAR: 字符型 MPI_UNSIGNED_CHAR: 无符号字符型MPI_BYTE: 字节型MPI_SHORT: 短整型MPI_UNSIGNED_SHORT: 无符号短整型MPI_INT: 整型MPI_UNSIGNED: 无符号整型MPI_LONG: 长整型MPI_UNSIGNED_LONG: 无符号长整型MPI_FLOAT: 单精度浮点型MPI_DOUBLE: 双精度浮点型M…

内置类型

MPI_CHAR: 字符型

  • MPI_UNSIGNED_CHAR: 无符号字符型
  • MPI_BYTE: 字节型
  • MPI_SHORT: 短整型
  • MPI_UNSIGNED_SHORT: 无符号短整型
  • MPI_INT: 整型
  • MPI_UNSIGNED: 无符号整型
  • MPI_LONG: 长整型
  • MPI_UNSIGNED_LONG: 无符号长整型
  • MPI_FLOAT: 单精度浮点型
  • MPI_DOUBLE: 双精度浮点型
  • MPI_LONG_DOUBLE: 长双精度浮点型

自定义类型

MPI_Type_contiguous: 创建一个由相同大小的元素组成的类型

函数原型

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

参数详解

  • count:新类型中元素的数量。
  • oldtype:待复制元素的类型。
  • newtype:返回一个新类型。

MPI_Type_vector: 创建一个由相同大小、位于相隔固定间距的元素组成的类型

函数原型

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

参数详解

  • count:向量中连续元素的数量。
  • blocklength:向量中相邻元素之间的间距。
  • stride:元素之间的间距(读取到该元素后,要跳过多少个元素才能读取下一个元素)。
  • oldtype:待复制元素的类型。
  • newtype:返回一个新类型。

MPI_Type_create_struct: 创建一个由不同类型的元素组成的类型

函数原型

int MPI_Type_create_struct(int count, const int* array_of_blocklengths, 
const MPI_Aint* array_of_displacements,
const MPI_Datatype* array_of_types, MPI_Datatype* newtype)

参数详解

  • count:新类型中元素的数量。
  • array_of_blocklengths:指定每个元素的长度。
  • array_of_displacements:指定每个元素的偏移量。需要注意的是,对于数组类型,偏移量必须是 MPI_Aint 类型。
  • array_of_types:指定每个元素的类型。
  • newtype:返回一个新类型。

代码实例

#include <stdio.h>
#include <mpi.h>typedef struct {int x, y;
} Vector2D;int main(int argc, char** argv) {int size, rank;MPI_Init(&argc, &argv);MPI_Comm_size(MPI_COMM_WORLD, &size);MPI_Comm_rank(MPI_COMM_WORLD, &rank);MPI_Datatype Vector2D_type;MPI_Type_vector(1, 2, 3, MPI_INT, &Vector2D_type);const MPI_Aint displacements[] = {0, offsetof(Vector2D, y)};const int blocklengths[] = {1, 1};MPI_Datatype types[] = {MPI_INT, MPI_INT};MPI_Type_create_struct(2, blocklengths, displacements, types, &Vector2D_type);MPI_Type_commit(&Vector2D_type);if (rank == 0) {Vector2D v = {1, 2};MPI_Send(&v, 1, Vector2D_type, 1, 0, MPI_COMM_WORLD);printf("Process 0 sent vector [%d, %d] to process 1\n", v.x, v.y);} else if (rank == 1) {Vector2D v_recv;MPI_Recv(&v_recv, 1, Vector2D_type, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);printf("Process 1 received vector [%d, %d] from process 0\n", v_recv.x, v_recv.y);}MPI_Type_free(&Vector2D_type);MPI_Finalize();return 0;
}

MPI_Type_indexed函数创建一个由相同大小的元素组成的类型,但这些元素并不连续,而是位于一个数组的不同位置

函数原型

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

参数详解

  • count:新类型中元素的数量。
  • array_of_blocklengths:一个整数数组,指定每个块中连续元素的数量。
  • array_of_displacements:一个整数数组,指定每个块的起始位置。
  • oldtype:待复制元素的类型。
  • newtype:返回一个新类型。

代码实例

#include <stdio.h>
#include <mpi.h>int main(int argc, char** argv) {int size, rank;MPI_Init(&argc, &argv);MPI_Comm_size(MPI_COMM_WORLD, &size);MPI_Comm_rank(MPI_COMM_WORLD, &rank);int block_lengths[3] = {2, 3, 2};int displacements[3] = {0, 4, 12};int data[7] = {1, 2, 3, 4, 5, 6, 7};MPI_Datatype Complex_type;MPI_Type_indexed(3, block_lengths, displacements, MPI_INT, &Complex_type);MPI_Type_commit(&Complex_type);if (rank == 0) {printf("Sending complex data...\n");MPI_Send(data, 1, Complex_type, 1, 0, MPI_COMM_WORLD);} else if (rank == 1) {int recv_data[7];MPI_Recv(recv_data, 7, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);printf("Received complex data: [");for (int i = 0; i < 7; i++) {printf("%d ", recv_data[i]);}printf("]\n");}MPI_Type_free(&Complex_type);MPI_Finalize();return 0;
}

MPI_Type_hvector 创建一个向量数据类型,但与 MPI_Type_vector 不同的是,所有的数据元素不需要具有相同的大小和类型。具体来说,MPI_Type_hvector 允许用户按照任意的字节长距离来描述向量的结构

函数原型

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

参数详解

  • count:向量中元素的数量。
  • blocklength:向量中每个元素的个数。
  • stride:相邻元素之间的偏移(以字节为单位)。
  • oldtype:要重复的原始数据类型。
  • newtype:输出的新数据类型。

代码实例
假设有一个数组 a,它的每个元素的大小是 4 字节,我们想要创建一个新的 MPI 类型,每 2 个元素组合在一起,组成一个长度为 8 字节的结构体。在这种情况下,我们可以使用 MPI_Type_hvector 来创建新的数据类型:

MPI_Datatype struct_type, temp_type;
MPI_Type_contiguous(2, MPI_INT, &temp_type);
MPI_Type_create_resized(temp_type, 0, 8, &struct_type);
MPI_Type_commit(&struct_type);
MPI_Type_free(&temp_type);MPI_Datatype vector_type;
MPI_Type_hvector(4, 1, 8, struct_type, &vector_type);
MPI_Type_commit(&vector_type);
http://www.yayakq.cn/news/950492/

相关文章:

  • 外贸商城网站模板电脑网站转手机版
  • 百度网盘可以做网站吗南京师范大学课程建设网站
  • 湖南湘源建设工程有限公司网站好的设计教程网站
  • 长沙网站设计工作室图片上传分享平台
  • 网站照片要求学校网站建设软件推荐
  • 湖州企业网站开发公司网站建设与单位干部作风的关系
  • 网站的建设与维护工资软件专业做学校网站论文怎么选题
  • 花都网站制作手机免费创网站
  • 中山做外贸网站建设杭州优化公司哪家好
  • 生态建筑建设公司网站昆明北京网站建设
  • 提供网站建设运营公司资质国外超酷网站
  • 做编程的 网站重庆整合网络营销之整站优化
  • 平面设计接单网站有哪些农业网站平台建设方案
  • 河东网站建设注册网站网
  • 网站下雪特效wordpress 栏目显示不出来
  • 做淘宝客网站php互联网推广属于什么行业
  • 上海专业做网站公广州电商运营培训哪个机构好
  • 网站建设开发人员配置做酒业网站的要求
  • 网站主页设计欣赏公司装修费属于什么费用
  • 四川省工程建设管理协会网站做的好的网站开发
  • 手机站点cn做电商网站前端需要什么框架
  • 家庭做网站wordpress如何发表新文章
  • 四川seo技术培训seo黑帽优化
  • 做国外零售做什么网站工程网站建设
  • 志愿服务网站建设中标公告wordpress字段关联
  • 聊天网站建设网站建设买了服务器后怎么做
  • 得到做网站公司商汇通网站
  • 网站服务器租用4t多少钱一年啊linux php网站部署
  • 网站为什么上传不了图片商业网站用什么语言做
  • 培训行业门户网站建设福州网上店铺搭建公司