网站大量收购独家精品文档,联系QQ:2885784924

MPI并行程序编程-China-VO.ppt

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

创建新运算 归约 func是用户提供的用于完成运算的外部函数 commute用来指明所定义的运算是否满足交换律 一个运算创建后和MPI预定义的运算一样使用 归约 用户自定义函数 invec与inoutvec分别指出要被归约的数据所在缓冲的首地址 函数返回时,运算结果储存在inoutvec中 datatype指出归约对象的数据类型 len给出了invec与inoutvec中包含的元素个数(相当于归约函数中的count) 归约 Sample - Fortran PROGRAM UserOP C Run with 8 processes INCLUDE mpif.h INTEGER err, rank, size integer source, reslt EXTERNAL digit LOGICAL commute INTEGER myop CALL MPI_INIT(err) CALL MPI_COMM_RANK(MPI_WORLD_COMM,rank,err) CALL MPI_COMM_SIZE(MPI_WORLD_COMM,size,err) commute= true 满足交换律 call MPI_OP_CREATE(digit,commute,myop,err) source=(rank+1)**2 call MPI_BARRIER(MPI_COM_WORLD,err) call MPI_SCAN(source,reslt,1,MPI_INTEGER,myop,MPI_COMM_WORLD,err) print *,P:,rank, my result is ,reslt CALL MPI_OP_FREE(myop,err) CALL MPI_FINALIZE(err) END integer function digit(in,inout,len,type) integer len,type integer in(len),inout(len) do i=1,len inout(i)=mod((in(i)+inout(i)),10) end do digit=5 end Program Output P:6 my result is 0 P:5 my result is 1 P:7 my result is 4 P:1 my result is 5 P:3 my result is 0 P:2 my result is 4 P:4 my result is 5 P:0 my result is 1 source={ 1,4,9,16,25,36,49,64} MPI truly is a portable standard Source code portability between machines running MPI this is the “beauty” of having a standard Point-to-Point improve performance Derived Datatypes send a structure in C send a record in F90 send a collection of non-uniform data types Collective communication group of processes that do something together Both math and communications functions Virtual topologies method of making a collection of processes act like they are in a particular shap * * The arguments in the MPI_SEND call are “handles” briefly introduce arguments here - more detail will be

文档评论(0)

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

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

1亿VIP精品文档

相关文档