当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

华东师范大学:《高等数值分析(高性能计算/并行计算)》课程教学资源(讲义)07 消息传递编程接口 MPI(一)编程基础

资源类别:文库,文档格式:PDF,文档页数:44,文件大小:950.53KB,团购合买
MPI 安装、编译与运行 MPI 数据类型 消息发送和接收 MPI 一些常用函数
点击下载完整版文档(PDF)

華束師免天学|数学科学学院 School of Mathematical Sciences.East China Normal University 消息传递编程接口MPI (一)MPI编程基础 http://math.ecnu.edu.cn/-jypan

http://math.ecnu.edu.cn/~jypan 消息传递编程接口 MPI (一)MPI 编程基础

华东师范大学数学科学学院 目录页 School of Mathematical Sciences,ECNU Contents MPI安装、编译与运行 2 MPI数据类型 3 消息发送和接收 MPI一些常用函数 http://math.ecnu.edu.cn/-jypan

http://math.ecnu.edu.cn/~jypan 目录页 Contents 华东师范大学 数学科学学院 School of Mathematical Sciences, ECNU http://math.ecnu.edu.cn/~jypan 1 2 MPI 安装、编译与运行 MPI 数据类型 3 消息发送和接收 4 MPI 一些常用函数

华东师范大学数学科学学院 目录页 School of Mathematical Sciences,ECNU Contents MPI安装、编译与运行 1 MPI安装、编译与运行 2 MPI数据类型 3 消息发送和接收 4 MPI一些常用函数 http://math.ecnu.edu.cn/-jypan

http://math.ecnu.edu.cn/~jypan 目录页 Contents 华东师范大学 数学科学学院 School of Mathematical Sciences, ECNU http://math.ecnu.edu.cn/~jypan 1 2 MPI 安装、编译与运行 1 MPI 安装、编译与运行 3 MPI 数据类型 4 消息发送和接收 MPI 一些常用函数

MPI介绍 MPI:Message Passing Interface ● https://www.mpi-forum.org/ ● 消息传递编程标准,提供一个高效、可扩展、统一的并行编程环境,是 目前最为通用的分布式并行编程方式。 ●MPI是一种消息传递编程模型,是一种标准或规范,MPI实现通过提供 库函数实现进程间通信,从而进行并行计算,目前所有并行机制造商都 提供对MPI的支持。 ●MP1是一个库,不是一门语言,最终目的是服务于进程间通信 The goal of the Message-Passing Interface,simply stated,is to develop a widely used standard for writing message-passing programs.As such the interface should establish a practical,portable,efficient,and flexible standard for message passing. http://math.ecnu.edu.cn/-jypan A

http://math.ecnu.edu.cn/~jypan 4 MPI 介绍  https://www.mpi-forum.org/  消息传递编程标准,提供一个高效、可扩展、统一的并行编程环境,是 目前最为通用的分布式并行编程方式。  MPI 是一种消息传递编程模型,是一种标准或规范,MPI 实现通过提供 库函数实现进程间通信,从而进行并行计算,目前所有并行机制造商都 提供对MPI 的支持。  MPI 是一个库,不是一门语言,最终目的是服务于进程间通信 The goal of the Message-Passing Interface, simply stated, is to develop a widely used standard for writing message-passing programs. As such the interface should establish a practical, portable, efficient, and flexible standard for message passing. MPI:Message Passing Interface

MPI介绍 MPI的目标 ● 高通信性能,高可移植性,强大的功能 Practical,Portable,Efficient,Flexible MPI标准和MPI实现 1994年MP-1.0;1998年MP-2.0;2012年MP-3.0; ● MP-3.1(2015);MP1-4.0(2021);MP1-5.0(Current Efforts) ● 支持C和Fortran(目前以Fortran90为主) ●MPI实现(免费版):MPICH和OpenMPI 。MPI实现(商业版):Intel MPI,.BM MPI,HP-MPI,MS-MPl,·. ●所有版本都遵循MPI标准,可以不加修改地运行 http://math.ecnu.edu.cn/-jypan

http://math.ecnu.edu.cn/~jypan 5 MPI 介绍  高通信性能,高可移植性,强大的功能  Practical,Portable,Efficient,Flexible MPI 的目标  1994 年 MPI-1.0;1998 年 MPI-2.0;2012年 MPI-3.0; MPI-3.1 (2015);MPI-4.0 (2021) ; MPI-5.0 (Current Efforts)  支持 C 和 Fortran(目前以 Fortran 90 为主)  MPI 实现(免费版):MPICH 和 OpenMPI  MPI 实现(商业版):Intel MPI,IBM MPI,HP-MPI,MS-MPI,. . .  所有版本都遵循 MPI 标准,可以不加修改地运行 MPI 标准和 MPI 实现

MPICH下载与安装 MPICH ● http://www.mpich.org/ ●支持C/C++/Fortran ●支持编译器:GNU,Clang,Intel,,PGl,XL(lBM),Sun Studio ●安装:apt(Ubuntu4.0.2),yum(Fedora4.0.2) ● 手工安装:下载源代码(4.1.1)后编译 http://math.ecnu.edu.cn/-jypan 6

http://math.ecnu.edu.cn/~jypan 6 MPICH 下载与安装  http://www.mpich.org/  支持 C/C++/Fortran  支持编译器:GNU,Clang,Intel,PGI,XL (IBM),Sun Studio  安装:apt (Ubuntu 4.0.2),yum (Fedora 4.0.2)  手工安装:下载源代码 (4.1.1) 后编译 MPICH

第一个MPI程序 #include #include int main(int argc,char argv[]) MPI_Init(&argc,&argv); printf("Hello World!\n"); MPI_Finalize(); return 0; mpicc -02 -o hello MPI_hello.c mpirun -np 4 hello http://math.ecnu.edu.cn/-jypan 7

http://math.ecnu.edu.cn/~jypan 7 第一个 MPI 程序 #include #include int main(int argc, char * argv[]) { MPI_Init(&argc, &argv); printf("Hello World!\n"); MPI_Finalize(); return 0; } mpicc –O2 –o hello MPI_hello.c mpirun –np 4 hello

程序分析 #include MPICH相对于C语言的头文件 MPI_Init(&argc,&argv) MPI程序的开始 MPI_Finalize() MPI程序的结束。 MPI程序的开始和结束必须是MPI_Init和MPI_Finalize,分别完成MPI 的初始化和结束工作 http://math.ecnu.edu.cn/-jypan 8

http://math.ecnu.edu.cn/~jypan 8 程序分析 #include MPICH 相对于 C 语言的头文件 MPI_Init(&argc, &argv) MPI 程序的开始 MPI_Finalize() MPI 程序的结束。 MPI 程序的开始和结束必须是 MPI_Init 和 MPI_Finalize,分别完成 MPI 的初始化和结束工作

第二个MPI程序 MPI_hello.c #include #include #include int main(int argc,char argv[]) { int myid,np; int namelen; char proc_name[MPI_MAX_PROCESSOR_NAME]; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&myid); MPI_Comm_size(MPI_COMM_WORLD,&np); MPI_Get_processor_name(proc_name,&namelen); fprintf(stderr,"Hello,I am proc.%d of %d on %s\n", myid,np,proc_name); MPI_Finalize(); http://math.ecnu.edu.cn/-jypan 9

http://math.ecnu.edu.cn/~jypan 9 第二个 MPI 程序 #include #include #include int main(int argc, char * argv[]) { int myid, np; int namelen; char proc_name[MPI_MAX_PROCESSOR_NAME]; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Comm_size(MPI_COMM_WORLD, &np); MPI_Get_processor_name(proc_name,&namelen); fprintf(stderr,"Hello, I am proc. %d of %d on %s\n", myid, np, proc_name); MPI_Finalize(); } MPI_hello.c

程序分析 MPI MAX PROCESSOR NAME 预定义的宏,即MPI所允许的机器名字的最大长度 ●MPI Comm rank 函数,返回到本进程的进程号 ●MPI Comm size 函数,返回所有参加运算的进程的个数 MPI_Get_processor_name 函数,返回运行本进程所在的结点的主机名 http://math.ecnu.edu.cn/-jypan 10

http://math.ecnu.edu.cn/~jypan 10 程序分析  MPI_MAX_PROCESSOR_NAME 预定义的宏,即 MPI 所允许的机器名字的最大长度  MPI_Comm_rank 函数,返回到本进程的进程号  MPI_Comm_size 函数,返回所有参加运算的进程的个数  MPI_Get_processor_name 函数,返回运行本进程所在的结点的主机名

点击下载完整版文档(PDF)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共44页,可试读15页,点击继续阅读 ↓↓
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有