Python MPI广播排
因此,我正在尝试将一排Numpy阵列广播到每个节点,并在其自己的矩阵中将每个节点更新该特定行更新。
因此,代码如下:
comm.Bcast([A[i, i:], A[i, i:].size, MPI.DOUBLE], root = root)
其中a的类型为numpy.Array
,其中i
是迭代变量。 当我尝试这样做时,我以a
成为无
结束。
做到这一点的正确方法是什么?
So I'm trying to broadcast a row of an numpy array to every node, and have every node update that specific row in their own matrix.
So the code is as follows:
comm.Bcast([A[i, i:], A[i, i:].size, MPI.DOUBLE], root = root)
Where A is of type numpy.array
and where i
is an iteration variable.
When I try doing this, I ended with A
becoming None
.
What would the correct way be to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这需要一些数字骗局。您需要使用缓冲区的
.data
,然后将其变成带有偏移量的新的Numpy缓冲区。这应该接近您想要的内容:请注意,这需要您选择的元素是连续的。对于发送一列,您需要派生类型。
This requires some numpy trickery. You need to take the
.data
of the buffer, and turn it into a new numpy buffer with offset and all that. This should be close to what you want:Note that this requires that the elements you pick are contiguous. For sending a column you'd need derived types.