【转载】 Parallel Computing in Python using mpi4py
原地址:
https://research.computing.yale.edu/sites/default/files/files/mpi4py.pdf

=============================================
说明:
本文只摘录了部分因为比较重点的部分内容,如要查阅全部请关注原地址:
https://research.computing.yale.edu/sites/default/files/files/mpi4py.pdf


感觉效果比较好的就是下面的对通信的集合操作的图解,刚一看比较懵,细一看发现还比较形象。





=====================================================
示例代码:
import numpy as np
from mpi4py import MPI def rbind(comm, x):
return np.vstack(comm.allgather(x)) comm = MPI.COMM_WORLD x = np.arange(4, dtype=np.int) * comm.Get_rank()
a = rbind(comm, x) print(a)
import numpy as np
from mpi4py import MPI def rbind2(comm, x):
size = comm.Get_size()
m = np.zeros((size, len(x)), dtype=np.int)
comm.Allgather([x, MPI.INT], [m, MPI.INT])
return m comm = MPI.COMM_WORLD x = np.arange(4, dtype=np.int) * comm.Get_rank()
a = rbind2(comm, x) print(a)
import numpy as np
import math
from mpi4py import MPI comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size() x = range(20)
m = int(math.ceil(float(len(x)) / size))
x_chunk = x[rank*m:(rank+1)*m]
r_chunk = map(math.sqrt, x_chunk)
r = comm.allreduce(list(r_chunk)) if rank == 0:
print(len(r), r)
【转载】 Parallel Computing in Python using mpi4py的更多相关文章
- Introduction to Parallel Computing
Copied From:https://computing.llnl.gov/tutorials/parallel_comp/ Author: Blaise Barney, Lawrence Live ...
- General mistakes in parallel computing
这是2013年写的一篇旧文,放在gegahost.net上面 http://raison.gegahost.net/?p=97 March 11, 2013 General mistakes in ...
- Method and apparatus for an atomic operation in a parallel computing environment
A method and apparatus for a atomic operation is described. A method comprises receiving a first pro ...
- 转载八个最佳Python IDE
八个最佳Python IDE 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs Python是一种功能强大.语言简洁的编程语言.本文向大家推荐8个适合Pyt ...
- GPU Accelerated Computing with Python
https://developer.nvidia.com/how-to-cuda-Python python is one of the fastest growing and most popula ...
- 转载 为什么print在Python 3中变成了函数?
转载自编程派http://codingpy.com/article/why-print-became-a-function-in-python-3/ 原作者:Brett Cannon 原文链接:htt ...
- [转载]windows下安装Python虚拟环境virtualenvwrapper-win
1 前言 由于Python的版本众多,还有Python2和Python3的争论,因此有些软件包或第三方库就容易出现版本不兼容的问题. 通过 virtualenv 这个工具,就可以构建一系列 虚拟的Py ...
- [转载]windows下安装Python虚拟环境virtualenv,virtualenvwrapper-win
1 前言 由于Python的版本众多,还有Python2和Python3的争论,因此有些软件包或第三方库就容易出现版本不兼容的问题. 通过 virtualenv 这个工具,就可以构建一系列 虚拟的Py ...
- 转载:爬虫技术浅析(Python)
http://drops.wooyun.org/tips/3915 0x00 前言 网络爬虫(Web crawler),是一种“自动化浏览网络”的程序,或者说是一种网络机器人.它们被广泛用于互联网搜索 ...
- STROME --realtime & online parallel computing
Data Collections ---> Stream to Channel (as source input) ----> Parallel Computing---> Resu ...
随机推荐
- Vue学习:4.v-model使用
第一节算是对v-model的粗略了解,仅仅是将input的输入与Vue 实例的数据之间双向绑定.这一节将更详细的了解v-model在不同表单元素中的使用. v-model实例:找对象 实现功能: 使用 ...
- 妙用OSGraph:发掘GitHub知识图谱上的开源故事
1. 何为OSGraph? OSGraph (Open Source Graph) 是一个开源图谱关系洞察工具,基于GitHub开源数据全域图谱,实现开发者行为.项目社区生态的分析洞察.可以为开发者. ...
- 5分钟带你了解RabbitMQ的(普通/镜像)集群
前言 让我们深入探讨RabbitMQ的集群配置,了解各种集群模式的利弊.本次讨论的重点是帮助您快速理解RabbitMQ集群的运作方式,以及选择最适合您需求的模式.好的,话不多说.在RabbitMQ中, ...
- Java邮件发送解决ssl javax.mail实现方式
package test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.activation.DataH ...
- 向Web服务器端上传文件
server.py import flaskapp = flask.Flask(__name__)@app.route('/upload', methods=['POST'])def uploadFi ...
- 小米便签AS部署之Git的基本使用
1 项目测试截图 及仓库地址 https://gitee.com/magicfatblink/Notes-master 2 小米便签代码的移植 2.1 IDE 的准备 2.1.1 AS版本选择 由于小 ...
- GitHub上狂揽62Kstars的程序员做饭指南
写在前面 作为一名程序员,我们经常会在全球最大的同性交友网站 GitHub上寻找一些优质的开源项目来学习,以提升自己的专业技能. 今天给大家推荐的是一个GitHub上狂揽61K的开源项目.项目名叫做H ...
- Apline部署K3s的Agent
之前我们在Ubuntu上部署了K3s的Server节点(传送门),这次我们加入两台K3s的Agent节点搭建一个K3s的3节点工作环境. 需要准备好网络环境,确保三台VM之间是可以ping通的,设置好 ...
- RPC和心跳机制
hadoop在节点间的内部通讯使用的是RPC,RPC协议把消息翻译成二进制字节流发送到远程节点,远程节点再通过反序列化把二进制流转成原始的信息. namenode与datanode之间的通信,jobt ...
- [UG 二次开发 PYTHON] 添加螺纹规格
NX 1988 系列 在添加螺纹特征时,不能自定义螺纹规格, 从网上找到的资料上讲,改一个XML文件,在文件中添加自定义的螺纹规格,从而实现需要的效果. 自己写了一个小程序,方便手动添加螺纹规格. 效 ...