高性能计算导论-MPIProgramming摘要.ppt

  1. 1、本文档共23页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
高性能计算导论-MPIProgramming摘要

MPI Programming MPI Introduction MPI-Message Passing Interface MPI is a library, not a programming language MPI is a standard, not a specific implementation Implementations of MPI Specification MPICH (Argonne) MSMPI (Microsoft) MPI程序的初始化 任何一个MPI程序在调用MPI函数之前,首先调用的是初始化函数MPI_INIT. 建立MPI的执行环境 int MPI_Init(int *argc, char ***argv) Input Parameters: * argc - Pointer to the number of arguments * * * argv - Pointer to the argument vector 将命令行参数传给各个进程 获取通信域包含的进程数 MPI_Comm_size(MPI_Comm, int *size) MPI_Comm的默认值为MPI_COMM_WORLD,它包括了初始化时可得的全部进程。 函数返回时,size中存放指定通信域中的进程数。 获取当前进程标识 MPI_Comm_rank(MPI_Comm comm, int *rank) 函数返回时,rank中存放当前进程在给定的通信域中的进程标识号。 进程标识号用来将自身和其它的进程区别开来,实现进程间的通信。 消息发送 源进程将缓存中的数据发送到目的进程 MPI_Send(void* buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm) buf:发送缓存的起始地址 count:发送的数据个数 datatype:数据类型 dest:目的进程标识号 Tag:消息标志 comm:通信域 MPI预定义的数据类型 消息接收 目的进程从源进程接受数据,存入缓存中 MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status) buf:接收缓存的起始地址 count:最多可接收的数据个数 datatype:数据类型 source:发送数据的进程标识号 Tag:消息标志 comm:通信域 Status:返回状态 MPI程序结束 MPI程序的最后一个调用必须为: MPI_Finalize() 结束MPI程序的执行 Hello World Illustration of point-to-point message passing Sender receiver must match Count and datatype Tag and communicator MPI应用环境 应用环境的基本元素 N 个进程:0——N-1 进程之间的通信路径 通信域MPI_COMM_WORLD 进程的集合以及通路 MPI_Comm_size:进程的总数N MPI_Comm_rank:某一进程的具体标识 编译及运行(linux) Mpicc –o hello hello.c Mpirun –np 4 ./hello Notes on program example Each statement executes independently in each process MPI_COMM_WORLD is defined by mpi.h mpi.h must be #included MPI的常用组通信接口---广播 根进程将一条消息发送到组内的所有其它的进程,同时也包括它本身在内。 MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) buffer:通信消息缓存的起始地址 count:数据个数 datatype:数据类型 root:根进程的标识号 comm:通信域 MPI的常用组通信接口---归约 将每个进程缓冲区中的数据按给定的操作进行计算,并将计算结果返回到根进程的输出缓冲区中。 MPI_Reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype, MPI_Op op, int root, MPI_Comm comm) sendbuf:发送消息缓存的起始地址 recvbuf:接

文档评论(0)

ee88870 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档