简体   繁体   English

MPI4Py散点sendbuf参数类型?

[英]MPI4Py Scatter sendbuf Argument Type?

I'm having trouble with the Scatter function in the MPI4Py Python module. 我在MPI4Py Python模块中的Scatter函数遇到问题。 My assumption is that I should be able to pass it a single list for the sendbuffer. 我的假设是我应该能够将其传递给sendbuffer的单个列表。 However, I'm getting a consistent error message when I do that, or indeed add the other two arguments, recvbuf and root: 但是,当我这样做时,或者确实添加了其他两个参数recvbuf和root时,我得到的是一致的错误消息:

  File "code/step3.py", line 682, in subbox_grid
    i = mpi_communicator.Scatter(station_range, station_data)
  File "Comm.pyx", line 427, in mpi4py.MPI.Comm.Scatter (src/
mpi4py_MPI.c:44993)
  File "message.pxi", line 321, in mpi4py.MPI._p_msg_cco.for_scatter
(src/mpi4py_MPI.c:14497)
  File "message.pxi", line 232, in mpi4py.MPI._p_msg_cco.for_cco_send
(src/mpi4py_MPI.c:13630)
  File "message.pxi", line 36, in mpi4py.MPI.message_simple (src/
mpi4py_MPI.c:11904)
ValueError: message: expecting 2 or 3 items

Here is the relevant code snipped, starting a few lines above 682 mentioned above. 这是相关的代码片段,从上面提到的682几行开始。

for station in stations
        #snip--do some stuff with station
        station_data = []
        station_range = range(1,len(station))
        mpi_communicator = MPI.COMM_WORLD
        i = mpi_communicator.Scatter(station_range, nsm)
        #snip--do some stuff with station[i]
        nsm = combine(avg, wt, dnew, nf1, nl1, wti[i], wtm, station[i].id)
        station_data = mpi_communicator.Gather(station_range, nsm)

I've tried a number of combinations initializing station_range, but I must not be understanding the Scatter argument types properly. 我尝试了多种初始化station_range的组合,但是我一定不能正确理解Scatter参数类型。

Does a Python/MPI guru have a clarification this? Python / MPI专家对此有澄清吗?

If you want to move raw buffers (as with Gather ), you provide a triplet [buffer, size, type] . 如果要移动原始缓冲区(与Gather ),请提供一个三元组[buffer, size, type] Look at the demos for examples of this. 查看演示中的示例。 If you want to send Python objects, you should use the higher level interface and call gather (note the lowercase) which uses pickle internally. 如果你想发送的Python对象,你应该使用更高级别的接口并调用gather (注意是小写),它使用pickle内部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM