CharmPy- 分布式并行编程框架(charmp英文怎么读)

网友投稿 737 2022-10-11

CharmPy- 分布式并行编程框架(charmp英文怎么读)

CharmPy- 分布式并行编程框架(charmp英文怎么读)

CharmPy

CharmPy 是一个通用的分布式并行编程框架,具有简单而强大的 API ,基于可迁移的 Python 对象和远程方法调用; 构建于自适应 C ++运行时系统之上,提供速度、可扩展性和动态负载平衡。

CharmPy 允许开发从笔记本电脑到超级计算机的并行应用程序。

简单示例

from charmpy import charm, Chare, Group, Reducerfrom math import piimport timeclass Worker(Chare):    def work(self, n_steps, pi_future):        h = 1.0 / n_steps        s = 0.0        for i in range(self.thisIndex, n_steps, charm.numPes()):            x = h * (i + 0.5)            s += 4.0 / (1.0 + x**2)        # perform a reduction among members of the group, sending the result to the future        self.contribute(s * h, Reducer.sum, pi_future)def main(args):    n_steps = 1000    if len(args) > 1:        n_steps = int(args[1])    mypi = charm.createFuture()    workers = Group(Worker)  # create one instance of Worker on every processor    t0 = time.time()    workers.work(n_steps, mypi)  # invoke 'work' method on every worker    print('Approximated value of pi is:', mypi.get(),  # 'get' blocks until result arrives          'Error is', abs(mypi.get() - pi), 'Elapsed time=', time.time() - t0)    charm.exit()charm.start(main)

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:什么是 “动态规划” , 用两个经典问题举例。
下一篇:Spring boot 上传图片
相关文章

 发表评论

暂时没有评论,来抢沙发吧~