python - MPI.Op 和执行操作

标签 python mpi4py

我想使用 MPI.Op 类来执行由它的实例表示的某些操作(在本例中为 MPI.SUM)。

这是我的片段:

input = numpy.array(3, dtype='i')
output = numpy.array(3, dtype='i')
MPI.SUM.Reduce_local(input, output)

但是当我尝试运行它时,我得到了这个回溯:

Traceback (most recent call last):
  File "./mpi.py", line 37, in <module>
    MPI.SUM.Reduce_local(input, output)
  File "Op.pyx", line 75, in mpi4py.MPI.Op.Reduce_local (src/mpi4py.MPI.c:54825)
AttributeError: 'mpi4py.MPI.Op' object has no attribute 'scount'

我是Python新手,所以我很可能犯了一些简单的错误。有什么想法吗?

我使用的是 Python 2.6.6。

最佳答案

好的,这个问题我有答案了。

这似乎是 mpi4py 库中的一个错误,现已修复: https://bitbucket.org/mpi4py/mpi4py/commits/43c7388ad740e90cc7074c1c21857c3fd3880190

但是如果您没有最新版本的 mpi4py,您仍然可以这样做:

buffers = [[1,1],[2,2]]
result = reduce(MPI.SUM, buffers)

结果将是: [3,3]

关于python - MPI.Op 和执行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22622859/

相关文章:

python - 获取多索引中级别的最后一个元素

python - 在一个新的 Django 项目中,我应该使用基于类还是基于函数的 View ?

python - 使 Python 模块在 PyCharm 的 Ubuntu 环境中工作的问题

python - 在 tensorflow 中使用负损失

python - mpi4py 程序的意外输出

python - 与 mpi4py 中生成的进程相互通信?

python - 如何从pycharm中使用mpi4py(使用mpiexec)运行python脚本?

python - Ansible 不再有效

python - Hello_World 未在集群 :II 上使用 mpi4py